OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/i18n/encoding_detection.h" |
| 6 |
| 7 #include "third_party/ced/src/compact_enc_det/compact_enc_det.h" |
| 8 |
| 9 namespace base { |
| 10 |
| 11 bool DetectEncoding(const std::string& text, std::string* encoding) { |
| 12 int consumedBytes; |
| 13 bool isReliable; |
| 14 Encoding enc = CompactEncDet::DetectEncoding( |
| 15 text.c_str(), text.length(), nullptr, nullptr, nullptr, |
| 16 UNKNOWN_ENCODING, |
| 17 UNKNOWN_LANGUAGE, |
| 18 CompactEncDet::WEB_CORPUS, |
| 19 false, // Include 7-bit encodings |
| 20 &consumedBytes, |
| 21 &isReliable); |
| 22 |
| 23 if (enc == UNKNOWN_ENCODING) |
| 24 return false; |
| 25 |
| 26 *encoding = MimeEncodingName(enc); |
| 27 return true; |
| 28 } |
| 29 } // namespace base |
OLD | NEW |