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_I18N_CASE_CONVERSION_H_ | 5 #ifndef BASE_I18N_CASE_CONVERSION_H_ |
6 #define BASE_I18N_CASE_CONVERSION_H_ | 6 #define BASE_I18N_CASE_CONVERSION_H_ |
7 | 7 |
8 #include "base/i18n/base_i18n_export.h" | 8 #include "base/i18n/base_i18n_export.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 namespace i18n { | 13 namespace i18n { |
14 | 14 |
15 // Returns the lower case equivalent of string. Uses ICU's default locale. | 15 // UNICODE CASE-HANDLING ADVICE |
16 BASE_I18N_EXPORT string16 ToLower(const StringPiece16& string); | 16 // |
| 17 // In English it's always safe to convert to upper-case or lower-case text |
| 18 // and get a good answer. But some languages have rules specific to those |
| 19 // locales. One example is the Turkish I: |
| 20 // http://www.i18nguy.com/unicode/turkish-i18n.html |
| 21 // |
| 22 // ToLower/ToUpper use the current ICU locale which will take into account |
| 23 // the user language preference. Use this when dealing with user typing. |
| 24 // |
| 25 // FoldCase canonicalizes to a standardized form independent of the current |
| 26 // locale. Use this when comparing general Unicode strings that don't |
| 27 // necessarily belong in the user's current locale (like commands, protocol |
| 28 // names, other strings from the web) for case-insensitive equality. |
| 29 // |
| 30 // Note that case conversions will change the length of the string in some |
| 31 // not-uncommon cases. Never assume that the output is the same length as |
| 32 // the input. |
17 | 33 |
18 // Returns the upper case equivalent of string. Uses ICU's default locale. | 34 // Returns the lower case equivalent of string. Uses ICU's current locale. |
19 BASE_I18N_EXPORT string16 ToUpper(const StringPiece16& string); | 35 BASE_I18N_EXPORT string16 ToLower(StringPiece16 string); |
| 36 |
| 37 // Returns the upper case equivalent of string. Uses ICU's current locale. |
| 38 BASE_I18N_EXPORT string16 ToUpper(StringPiece16 string); |
| 39 |
| 40 // Convert the given string to a canonical case, independent of the current |
| 41 // locale. For ASCII the canonical form is lower case. |
| 42 // See http://unicode.org/faq/casemap_charprop.html#2 |
| 43 BASE_I18N_EXPORT string16 FoldCase(StringPiece16 string); |
20 | 44 |
21 } // namespace i18n | 45 } // namespace i18n |
22 } // namespace base | 46 } // namespace base |
23 | 47 |
24 #endif // BASE_I18N_CASE_CONVERSION_H_ | 48 #endif // BASE_I18N_CASE_CONVERSION_H_ |
OLD | NEW |