Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: ui/base/l10n/l10n_util.cc

Issue 8418034: Make string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ui/base/l10n/l10n_util.h" 5 #include "ui/base/l10n/l10n_util.h"
6 6
7 #if defined(USE_X11) 7 #if defined(USE_X11)
8 #include <glib/gutils.h> 8 #include <glib/gutils.h>
9 #endif 9 #endif
10 10
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 // 4. Patch ICU to special-case zh-Hans/zh-Hant for us. 471 // 4. Patch ICU to special-case zh-Hans/zh-Hant for us.
472 // #1 and #2 wouldn't work if display_locale != current UI locale although 472 // #1 and #2 wouldn't work if display_locale != current UI locale although
473 // we can think of additional hack to work around the problem. 473 // we can think of additional hack to work around the problem.
474 // #3 can be potentially expensive. 474 // #3 can be potentially expensive.
475 if (locale_code == "zh-CN") 475 if (locale_code == "zh-CN")
476 locale_code = "zh-Hans"; 476 locale_code = "zh-Hans";
477 else if (locale_code == "zh-TW") 477 else if (locale_code == "zh-TW")
478 locale_code = "zh-Hant"; 478 locale_code = "zh-Hant";
479 479
480 UErrorCode error = U_ZERO_ERROR; 480 UErrorCode error = U_ZERO_ERROR;
481 const int buffer_size = 1024; 481 const int kBufferSize = 1024;
482 482
483 string16 display_name; 483 string16 display_name;
484 int actual_size = uloc_getDisplayName(locale_code.c_str(), 484 int actual_size = uloc_getDisplayName(locale_code.c_str(),
485 display_locale.c_str(), 485 display_locale.c_str(),
486 WriteInto(&display_name, buffer_size + 1), buffer_size, &error); 486 WriteInto(&display_name, kBufferSize), kBufferSize - 1, &error);
487 DCHECK(U_SUCCESS(error)); 487 DCHECK(U_SUCCESS(error));
488 display_name.resize(actual_size); 488 display_name.resize(actual_size);
489 // Add an RTL mark so parentheses are properly placed. 489 // Add an RTL mark so parentheses are properly placed.
490 if (is_for_ui && base::i18n::IsRTL()) 490 if (is_for_ui && base::i18n::IsRTL())
491 display_name.push_back(static_cast<char16>(base::i18n::kRightToLeftMark)); 491 display_name.push_back(static_cast<char16>(base::i18n::kRightToLeftMark));
492 return display_name; 492 return display_name;
493 } 493 }
494 494
495 std::string NormalizeLocale(const std::string& locale) { 495 std::string NormalizeLocale(const std::string& locale) {
496 std::string normalized_locale(locale); 496 std::string normalized_locale(locale);
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 for (size_t i = 0; i < arraysize(kAcceptLanguageList); ++i) { 818 for (size_t i = 0; i < arraysize(kAcceptLanguageList); ++i) {
819 if (!IsLocaleNameTranslated(kAcceptLanguageList[i], display_locale)) 819 if (!IsLocaleNameTranslated(kAcceptLanguageList[i], display_locale))
820 // TODO(jungshik) : Put them at the of the list with language codes 820 // TODO(jungshik) : Put them at the of the list with language codes
821 // enclosed by brackets instead of skipping. 821 // enclosed by brackets instead of skipping.
822 continue; 822 continue;
823 locale_codes->push_back(kAcceptLanguageList[i]); 823 locale_codes->push_back(kAcceptLanguageList[i]);
824 } 824 }
825 } 825 }
826 826
827 } // namespace l10n_util 827 } // namespace l10n_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698