| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 #elif defined(OS_WIN) | 262 #elif defined(OS_WIN) |
| 263 rtl_safe_path->append(path.value()); | 263 rtl_safe_path->append(path.value()); |
| 264 #else // defined(OS_POSIX) && !defined(OS_MACOSX) | 264 #else // defined(OS_POSIX) && !defined(OS_MACOSX) |
| 265 std::wstring wide_path = base::SysNativeMBToWide(path.value()); | 265 std::wstring wide_path = base::SysNativeMBToWide(path.value()); |
| 266 rtl_safe_path->append(WideToUTF16(wide_path)); | 266 rtl_safe_path->append(WideToUTF16(wide_path)); |
| 267 #endif | 267 #endif |
| 268 // Inserting a PDF (Pop Directional Formatting) mark as the last character. | 268 // Inserting a PDF (Pop Directional Formatting) mark as the last character. |
| 269 rtl_safe_path->push_back(kPopDirectionalFormatting); | 269 rtl_safe_path->push_back(kPopDirectionalFormatting); |
| 270 } | 270 } |
| 271 | 271 |
| 272 std::wstring GetDisplayStringInLTRDirectionality(std::wstring* text) { | 272 string16 GetDisplayStringInLTRDirectionality(const string16& text) { |
| 273 if (IsRTL()) | 273 if (!IsRTL()) |
| 274 WrapStringWithLTRFormatting(text); | 274 return text; |
| 275 return *text; | 275 string16 text_mutable(text); |
| 276 WrapStringWithLTRFormatting(&text_mutable); |
| 277 return text_mutable; |
| 276 } | 278 } |
| 277 | 279 |
| 278 const string16 StripWrappingBidiControlCharacters(const string16& text) { | 280 const string16 StripWrappingBidiControlCharacters(const string16& text) { |
| 279 if (text.empty()) | 281 if (text.empty()) |
| 280 return text; | 282 return text; |
| 281 size_t begin_index = 0; | 283 size_t begin_index = 0; |
| 282 char16 begin = text[begin_index]; | 284 char16 begin = text[begin_index]; |
| 283 if (begin == kLeftToRightEmbeddingMark || | 285 if (begin == kLeftToRightEmbeddingMark || |
| 284 begin == kRightToLeftEmbeddingMark || | 286 begin == kRightToLeftEmbeddingMark || |
| 285 begin == kLeftToRightOverride || | 287 begin == kLeftToRightOverride || |
| 286 begin == kRightToLeftOverride) | 288 begin == kRightToLeftOverride) |
| 287 ++begin_index; | 289 ++begin_index; |
| 288 size_t end_index = text.length() - 1; | 290 size_t end_index = text.length() - 1; |
| 289 if (text[end_index] == kPopDirectionalFormatting) | 291 if (text[end_index] == kPopDirectionalFormatting) |
| 290 --end_index; | 292 --end_index; |
| 291 return text.substr(begin_index, end_index - begin_index + 1); | 293 return text.substr(begin_index, end_index - begin_index + 1); |
| 292 } | 294 } |
| 293 | 295 |
| 294 } // namespace i18n | 296 } // namespace i18n |
| 295 } // namespace base | 297 } // namespace base |
| OLD | NEW |