OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/i18n/icu_encoding_detection.h" | 5 #include "base/i18n/icu_encoding_detection.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "third_party/icu/public/i18n/unicode/ucsdet.h" | 10 #include "third_party/icu/source/i18n/unicode/ucsdet.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 | 13 |
14 bool DetectEncoding(const std::string& text, std::string* encoding) { | 14 bool DetectEncoding(const std::string& text, std::string* encoding) { |
15 if (IsStringASCII(text)) { | 15 if (IsStringASCII(text)) { |
16 *encoding = std::string(); | 16 *encoding = std::string(); |
17 return true; | 17 return true; |
18 } | 18 } |
19 | 19 |
20 UErrorCode status = U_ZERO_ERROR; | 20 UErrorCode status = U_ZERO_ERROR; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 if (sniffed_encodings.find(name) == sniffed_encodings.end()) | 95 if (sniffed_encodings.find(name) == sniffed_encodings.end()) |
96 encodings->push_back(name); | 96 encodings->push_back(name); |
97 } | 97 } |
98 uenum_close(detectable_encodings); | 98 uenum_close(detectable_encodings); |
99 | 99 |
100 ucsdet_close(detector); | 100 ucsdet_close(detector); |
101 return !encodings->empty(); | 101 return !encodings->empty(); |
102 } | 102 } |
103 | 103 |
104 } // namespace base | 104 } // namespace base |
OLD | NEW |