| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_STRING16_H_ | 5 #ifndef BASE_STRINGS_STRING16_H_ |
| 6 #define BASE_STRINGS_STRING16_H_ | 6 #define BASE_STRINGS_STRING16_H_ |
| 7 | 7 |
| 8 // WHAT: | 8 // WHAT: |
| 9 // A version of std::basic_string that provides 2-byte characters even when | 9 // A version of std::basic_string that provides 2-byte characters even when |
| 10 // wchar_t is not implemented as a 2-byte type. You can access this class as | 10 // wchar_t is not implemented as a 2-byte type. You can access this class as |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 namespace base { | 41 namespace base { |
| 42 | 42 |
| 43 typedef wchar_t char16; | 43 typedef wchar_t char16; |
| 44 typedef std::wstring string16; | 44 typedef std::wstring string16; |
| 45 typedef std::char_traits<wchar_t> string16_char_traits; | 45 typedef std::char_traits<wchar_t> string16_char_traits; |
| 46 | 46 |
| 47 } // namespace base | 47 } // namespace base |
| 48 | 48 |
| 49 #elif defined(WCHAR_T_IS_UTF32) | 49 #elif defined(WCHAR_T_IS_UTF32) |
| 50 | 50 |
| 51 #include <wchar.h> // for mbstate_t |
| 52 |
| 51 namespace base { | 53 namespace base { |
| 52 | 54 |
| 53 typedef uint16_t char16; | 55 typedef uint16_t char16; |
| 54 | 56 |
| 55 // char16 versions of the functions required by string16_char_traits; these | 57 // char16 versions of the functions required by string16_char_traits; these |
| 56 // are based on the wide character functions of similar names ("w" or "wcs" | 58 // are based on the wide character functions of similar names ("w" or "wcs" |
| 57 // instead of "c16"). | 59 // instead of "c16"). |
| 58 BASE_EXPORT int c16memcmp(const char16* s1, const char16* s2, size_t n); | 60 BASE_EXPORT int c16memcmp(const char16* s1, const char16* s2, size_t n); |
| 59 BASE_EXPORT size_t c16len(const char16* s); | 61 BASE_EXPORT size_t c16len(const char16* s); |
| 60 BASE_EXPORT const char16* c16memchr(const char16* s, char16 c, size_t n); | 62 BASE_EXPORT const char16* c16memchr(const char16* s, char16 c, size_t n); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 for (base::char16 c : s) | 197 for (base::char16 c : s) |
| 196 result = (result * 131) + c; | 198 result = (result * 131) + c; |
| 197 return result; | 199 return result; |
| 198 } | 200 } |
| 199 }; | 201 }; |
| 200 } // namespace std | 202 } // namespace std |
| 201 | 203 |
| 202 #endif // WCHAR_T_IS_UTF32 | 204 #endif // WCHAR_T_IS_UTF32 |
| 203 | 205 |
| 204 #endif // BASE_STRINGS_STRING16_H_ | 206 #endif // BASE_STRINGS_STRING16_H_ |
| OLD | NEW |