Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Unified Diff: net/ftp/ftp_directory_listing_parser.cc

Issue 2168003003: Replace ICU encoding detection with CED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments/add datafiles back Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/data/ftp/dir-listing-ls-22.expected ('k') | pdf/pdfium/pdfium_engine.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ftp/ftp_directory_listing_parser.cc
diff --git a/net/ftp/ftp_directory_listing_parser.cc b/net/ftp/ftp_directory_listing_parser.cc
index a1aabf3f971f39fe6d898b7681e97ae600cc99e1..73e831f66a11454ea3a4c3ffe9607c5ccd46474a 100644
--- a/net/ftp/ftp_directory_listing_parser.cc
+++ b/net/ftp/ftp_directory_listing_parser.cc
@@ -6,7 +6,7 @@
#include "base/bind.h"
#include "base/callback.h"
-#include "base/i18n/icu_encoding_detection.h"
+#include "base/i18n/encoding_detection.h"
#include "base/i18n/icu_string_conversions.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
@@ -84,29 +84,23 @@ int DecodeAndParse(const std::string& text,
const base::Time& current_time,
std::vector<FtpDirectoryListingEntry>* entries,
FtpServerType* server_type) {
- const char* const kNewlineSeparators[] = { "\n", "\r\n" };
-
- std::vector<std::string> encodings;
- if (!base::DetectAllEncodings(text, &encodings))
+ std::string encoding;
+ if (!base::DetectEncoding(text, &encoding))
return ERR_ENCODING_DETECTION_FAILED;
-
- // Use first encoding that can be used to decode the text.
- for (size_t i = 0; i < encodings.size(); i++) {
- base::string16 converted_text;
- if (base::CodepageToUTF16(text,
- encodings[i].c_str(),
- base::OnStringConversionError::FAIL,
- &converted_text)) {
- for (size_t j = 0; j < arraysize(kNewlineSeparators); j++) {
- int rv = ParseListing(converted_text,
- base::ASCIIToUTF16(kNewlineSeparators[j]),
- encodings[i],
- current_time,
- entries,
- server_type);
- if (rv == OK)
- return rv;
- }
+ const char* encoding_name = encoding.c_str();
+
+ base::string16 converted_text;
+ if (base::CodepageToUTF16(text, encoding_name,
cbentzel 2016/08/10 01:52:00 I assume that encoding names are the same in CED a
Jinsuk Kim 2016/08/10 02:15:13 They are not precisely the same. CED returns IANA
+ base::OnStringConversionError::FAIL,
+ &converted_text)) {
+ const char* const kNewlineSeparators[] = {"\n", "\r\n"};
+
+ for (size_t j = 0; j < arraysize(kNewlineSeparators); j++) {
+ int rv = ParseListing(converted_text,
+ base::ASCIIToUTF16(kNewlineSeparators[j]),
+ encoding_name, current_time, entries, server_type);
+ if (rv == OK)
+ return rv;
}
}
« no previous file with comments | « net/data/ftp/dir-listing-ls-22.expected ('k') | pdf/pdfium/pdfium_engine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698