case_conversion.h 1.8 KB

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