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 #include "base/i18n/rtl.h" | 5 #include "base/i18n/rtl.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 const char* variant = locale.getVariant(); | 29 const char* variant = locale.getVariant(); |
30 | 30 |
31 std::string result = | 31 std::string result = |
32 (language != NULL && *language != '\0') ? language : "und"; | 32 (language != NULL && *language != '\0') ? language : "und"; |
33 | 33 |
34 if (country != NULL && *country != '\0') { | 34 if (country != NULL && *country != '\0') { |
35 result += '-'; | 35 result += '-'; |
36 result += country; | 36 result += country; |
37 } | 37 } |
38 | 38 |
39 if (variant != NULL && *variant != '\0') { | 39 if (variant != NULL && *variant != '\0') |
40 std::string variant_str(variant); | 40 result += '@' + base::ToLowerASCII(variant); |
41 base::StringToLowerASCII(&variant_str); | |
42 result += '@' + variant_str; | |
43 } | |
44 | 41 |
45 return result; | 42 return result; |
46 } | 43 } |
47 | 44 |
48 // Returns LEFT_TO_RIGHT or RIGHT_TO_LEFT if |character| has strong | 45 // Returns LEFT_TO_RIGHT or RIGHT_TO_LEFT if |character| has strong |
49 // directionality, returns UNKNOWN_DIRECTION if it doesn't. Please refer to | 46 // directionality, returns UNKNOWN_DIRECTION if it doesn't. Please refer to |
50 // http://unicode.org/reports/tr9/ for more information. | 47 // http://unicode.org/reports/tr9/ for more information. |
51 base::i18n::TextDirection GetCharacterDirection(UChar32 character) { | 48 base::i18n::TextDirection GetCharacterDirection(UChar32 character) { |
52 // Now that we have the character, we use ICU in order to query for the | 49 // Now that we have the character, we use ICU in order to query for the |
53 // appropriate Unicode BiDi character type. | 50 // appropriate Unicode BiDi character type. |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 begin == kRightToLeftOverride) | 403 begin == kRightToLeftOverride) |
407 ++begin_index; | 404 ++begin_index; |
408 size_t end_index = text.length() - 1; | 405 size_t end_index = text.length() - 1; |
409 if (text[end_index] == kPopDirectionalFormatting) | 406 if (text[end_index] == kPopDirectionalFormatting) |
410 --end_index; | 407 --end_index; |
411 return text.substr(begin_index, end_index - begin_index + 1); | 408 return text.substr(begin_index, end_index - begin_index + 1); |
412 } | 409 } |
413 | 410 |
414 } // namespace i18n | 411 } // namespace i18n |
415 } // namespace base | 412 } // namespace base |
OLD | NEW |