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 #ifndef BASE_STRINGS_UTF_STRING_CONVERSION_UTILS_H_ | 5 #ifndef BASE_STRINGS_UTF_STRING_CONVERSION_UTILS_H_ |
6 #define BASE_STRINGS_UTF_STRING_CONVERSION_UTILS_H_ | 6 #define BASE_STRINGS_UTF_STRING_CONVERSION_UTILS_H_ |
7 | 7 |
8 // This should only be used by the various UTF string conversion files. | 8 // This should only be used by the various UTF string conversion files. |
9 | 9 |
10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
11 #include "base/string16.h" | 11 #include "base/strings/string16.h" |
12 | 12 |
13 namespace base { | 13 namespace base { |
14 | 14 |
15 inline bool IsValidCodepoint(uint32 code_point) { | 15 inline bool IsValidCodepoint(uint32 code_point) { |
16 // Excludes the surrogate code points ([0xD800, 0xDFFF]) and | 16 // Excludes the surrogate code points ([0xD800, 0xDFFF]) and |
17 // codepoints larger than 0x10FFFF (the highest codepoint allowed). | 17 // codepoints larger than 0x10FFFF (the highest codepoint allowed). |
18 // Non-characters and unassigned codepoints are allowed. | 18 // Non-characters and unassigned codepoints are allowed. |
19 return code_point < 0xD800u || | 19 return code_point < 0xD800u || |
20 (code_point >= 0xE000u && code_point <= 0x10FFFFu); | 20 (code_point >= 0xE000u && code_point <= 0x10FFFFu); |
21 } | 21 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 void PrepareForUTF8Output(const CHAR* src, size_t src_len, std::string* output); | 88 void PrepareForUTF8Output(const CHAR* src, size_t src_len, std::string* output); |
89 | 89 |
90 // Prepares an output buffer (containing either UTF-16 or -32 data) given some | 90 // Prepares an output buffer (containing either UTF-16 or -32 data) given some |
91 // UTF-8 input that will be converted to it. See PrepareForUTF8Output(). | 91 // UTF-8 input that will be converted to it. See PrepareForUTF8Output(). |
92 template<typename STRING> | 92 template<typename STRING> |
93 void PrepareForUTF16Or32Output(const char* src, size_t src_len, STRING* output); | 93 void PrepareForUTF16Or32Output(const char* src, size_t src_len, STRING* output); |
94 | 94 |
95 } // namespace base | 95 } // namespace base |
96 | 96 |
97 #endif // BASE_STRINGS_UTF_STRING_CONVERSION_UTILS_H_ | 97 #endif // BASE_STRINGS_UTF_STRING_CONVERSION_UTILS_H_ |
OLD | NEW |