| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef NET_BASE_NET_STRING_UTIL_H__ | 5 #ifndef NET_BASE_NET_STRING_UTIL_H__ |
| 6 #define NET_BASE_NET_STRING_UTIL_H__ | 6 #define NET_BASE_NET_STRING_UTIL_H__ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 | 11 |
| 12 // String conversion functions. By default, they're implemented with ICU, but | 12 // String conversion functions. By default, they're implemented with ICU, but |
| 13 // when building with USE_ICU_ALTERNATIVES, they use platform functions instead. | 13 // when building with USE_ICU_ALTERNATIVES, they use platform functions instead. |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 extern const char* const kCharsetLatin1; | 17 extern const char* const kCharsetLatin1; |
| 18 | 18 |
| 19 // Converts |text| using |charset| to UTF-8, and writes it to |output|. | 19 // Converts |text| using |charset| to UTF-8, and writes it to |output|. |
| 20 // On failure, returns false and |output| is cleared. | 20 // On failure, returns false and |output| is cleared. |
| 21 bool ConvertToUtf8(const std::string& text, const char* charset, | 21 bool ConvertToUtf8(const std::string& text, |
| 22 const char* charset, |
| 22 std::string* output); | 23 std::string* output); |
| 23 | 24 |
| 24 // Converts |text| using |charset| to UTF-8, normalizes the result, and writes | 25 // Converts |text| using |charset| to UTF-8, normalizes the result, and writes |
| 25 // it to |output|. On failure, returns false and |output| is cleared. | 26 // it to |output|. On failure, returns false and |output| is cleared. |
| 26 bool ConvertToUtf8AndNormalize(const std::string& text, const char* charset, | 27 bool ConvertToUtf8AndNormalize(const std::string& text, |
| 28 const char* charset, |
| 27 std::string* output); | 29 std::string* output); |
| 28 | 30 |
| 29 // Converts |text| using |charset| to UTF-16, and writes it to |output|. | 31 // Converts |text| using |charset| to UTF-16, and writes it to |output|. |
| 30 // On failure, returns false and |output| is cleared. | 32 // On failure, returns false and |output| is cleared. |
| 31 bool ConvertToUTF16(const std::string& text, const char* charset, | 33 bool ConvertToUTF16(const std::string& text, |
| 34 const char* charset, |
| 32 base::string16* output); | 35 base::string16* output); |
| 33 | 36 |
| 34 // Converts |text| using |charset| to UTF-16, and writes it to |output|. | 37 // Converts |text| using |charset| to UTF-16, and writes it to |output|. |
| 35 // Any characters that can not be converted are replaced with U+FFFD. | 38 // Any characters that can not be converted are replaced with U+FFFD. |
| 36 bool ConvertToUTF16WithSubstitutions(const std::string& text, | 39 bool ConvertToUTF16WithSubstitutions(const std::string& text, |
| 37 const char* charset, | 40 const char* charset, |
| 38 base::string16* output); | 41 base::string16* output); |
| 39 | 42 |
| 40 } // namespace net | 43 } // namespace net |
| 41 | 44 |
| 42 #endif // NET_BASE_NET_STRING_UTIL_H__ | 45 #endif // NET_BASE_NET_STRING_UTIL_H__ |
| OLD | NEW |