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/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 29 matching lines...) Expand all Loading... | |
40 return result; | 40 return result; |
41 } | 41 } |
42 | 42 |
43 // Returns LEFT_TO_RIGHT or RIGHT_TO_LEFT if |character| has strong | 43 // Returns LEFT_TO_RIGHT or RIGHT_TO_LEFT if |character| has strong |
44 // directionality, returns UNKNOWN_DIRECTION if it doesn't. Please refer to | 44 // directionality, returns UNKNOWN_DIRECTION if it doesn't. Please refer to |
45 // http://unicode.org/reports/tr9/ for more information. | 45 // http://unicode.org/reports/tr9/ for more information. |
46 base::i18n::TextDirection GetCharacterDirection(UChar32 character) { | 46 base::i18n::TextDirection GetCharacterDirection(UChar32 character) { |
47 // Now that we have the character, we use ICU in order to query for the | 47 // Now that we have the character, we use ICU in order to query for the |
48 // appropriate Unicode BiDi character type. | 48 // appropriate Unicode BiDi character type. |
49 int32_t property = u_getIntPropertyValue(character, UCHAR_BIDI_CLASS); | 49 int32_t property = u_getIntPropertyValue(character, UCHAR_BIDI_CLASS); |
50 if ((property == U_RIGHT_TO_LEFT) || | 50 if ((property == U_RIGHT_TO_LEFT) || (property == U_RIGHT_TO_LEFT_ARABIC) || |
51 (property == U_RIGHT_TO_LEFT_ARABIC) || | |
52 (property == U_RIGHT_TO_LEFT_EMBEDDING) || | 51 (property == U_RIGHT_TO_LEFT_EMBEDDING) || |
53 (property == U_RIGHT_TO_LEFT_OVERRIDE)) { | 52 (property == U_RIGHT_TO_LEFT_override)) { |
Mostyn Bramley-Moore
2014/09/30 22:43:58
incorrect match here
| |
54 return base::i18n::RIGHT_TO_LEFT; | 53 return base::i18n::RIGHT_TO_LEFT; |
55 } else if ((property == U_LEFT_TO_RIGHT) || | 54 } else if ((property == U_LEFT_TO_RIGHT) || |
56 (property == U_LEFT_TO_RIGHT_EMBEDDING) || | 55 (property == U_LEFT_TO_RIGHT_EMBEDDING) || |
57 (property == U_LEFT_TO_RIGHT_OVERRIDE)) { | 56 (property == U_LEFT_TO_RIGHT_override)) { |
Mostyn Bramley-Moore
2014/09/30 22:43:58
incorrect match here
| |
58 return base::i18n::LEFT_TO_RIGHT; | 57 return base::i18n::LEFT_TO_RIGHT; |
59 } | 58 } |
60 return base::i18n::UNKNOWN_DIRECTION; | 59 return base::i18n::UNKNOWN_DIRECTION; |
61 } | 60 } |
62 | 61 |
63 } // namespace | 62 } // namespace |
64 | 63 |
65 namespace base { | 64 namespace base { |
66 namespace i18n { | 65 namespace i18n { |
67 | 66 |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 begin == kRightToLeftOverride) | 384 begin == kRightToLeftOverride) |
386 ++begin_index; | 385 ++begin_index; |
387 size_t end_index = text.length() - 1; | 386 size_t end_index = text.length() - 1; |
388 if (text[end_index] == kPopDirectionalFormatting) | 387 if (text[end_index] == kPopDirectionalFormatting) |
389 --end_index; | 388 --end_index; |
390 return text.substr(begin_index, end_index - begin_index + 1); | 389 return text.substr(begin_index, end_index - begin_index + 1); |
391 } | 390 } |
392 | 391 |
393 } // namespace i18n | 392 } // namespace i18n |
394 } // namespace base | 393 } // namespace base |
OLD | NEW |