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 // Converts |text| using |charset| to UTF-8, and writes it to |output|. | 17 // Converts |text| using |charset| to UTF-8, and writes it to |output|. |
18 // On failure, returns false and |output| is cleared. | 18 // On failure, returns false and |output| is cleared. |
19 bool ConvertToUtf8(const std::string& text, const char* charset, | 19 bool ConvertToUtf8(const std::string& text, |
| 20 const char* charset, |
20 std::string* output); | 21 std::string* output); |
21 | 22 |
22 // Converts |text| using |charset| to UTF-8, normalizes the result, and writes | 23 // Converts |text| using |charset| to UTF-8, normalizes the result, and writes |
23 // it to |output|. On failure, returns false and |output| is cleared. | 24 // it to |output|. On failure, returns false and |output| is cleared. |
24 bool ConvertToUtf8AndNormalize(const std::string& text, const char* charset, | 25 bool ConvertToUtf8AndNormalize(const std::string& text, |
| 26 const char* charset, |
25 std::string* output); | 27 std::string* output); |
26 | 28 |
27 // Converts |text| encoded in Latin-1 to UTF-8, normalizes the result, and | 29 // Converts |text| encoded in Latin-1 to UTF-8, normalizes the result, and |
28 // writes it to |output|. On failure, returns false and |output| is cleared. | 30 // writes it to |output|. On failure, returns false and |output| is cleared. |
29 bool ConvertLatin1ToUtf8AndNormalize(const std::string& text, | 31 bool ConvertLatin1ToUtf8AndNormalize(const std::string& text, |
30 std::string* output); | 32 std::string* output); |
31 | 33 |
32 // Converts |text| using |charset| to UTF-16, and writes it to |output|. | 34 // Converts |text| using |charset| to UTF-16, and writes it to |output|. |
33 // On failure, returns false and |output| is cleared. | 35 // On failure, returns false and |output| is cleared. |
34 bool ConvertToUTF16(const std::string& text, const char* charset, | 36 bool ConvertToUTF16(const std::string& text, |
| 37 const char* charset, |
35 base::string16* output); | 38 base::string16* output); |
36 | 39 |
37 // Converts |text| encoded in Latin-1 to UTF-16, and writes it to |output|. | 40 // Converts |text| encoded in Latin-1 to UTF-16, and writes it to |output|. |
38 // On failure, returns false and |output| is cleared. | 41 // On failure, returns false and |output| is cleared. |
39 bool ConvertLatin1ToUTF16(const std::string& text, base::string16* output); | 42 bool ConvertLatin1ToUTF16(const std::string& text, base::string16* output); |
40 | 43 |
41 } // namespace net | 44 } // namespace net |
42 | 45 |
43 #endif // NET_BASE_NET_STRING_UTIL_H__ | 46 #endif // NET_BASE_NET_STRING_UTIL_H__ |
OLD | NEW |