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

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

Issue 176843022: Move UTF16ToASCII, remove WideToASCII. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months 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
« no previous file with comments | « skia/ext/vector_canvas_unittest.cc ('k') | ui/base/l10n/l10n_util_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include <algorithm> 7 #include <algorithm>
8 #include <cstdlib> 8 #include <cstdlib>
9 #include <iterator> 9 #include <iterator>
10 #include <string> 10 #include <string>
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 bool IsLocaleNameTranslated(const char* locale, 500 bool IsLocaleNameTranslated(const char* locale,
501 const std::string& display_locale) { 501 const std::string& display_locale) {
502 base::string16 display_name = 502 base::string16 display_name =
503 l10n_util::GetDisplayNameForLocale(locale, display_locale, false); 503 l10n_util::GetDisplayNameForLocale(locale, display_locale, false);
504 // Because ICU sets the error code to U_USING_DEFAULT_WARNING whether or not 504 // Because ICU sets the error code to U_USING_DEFAULT_WARNING whether or not
505 // uloc_getDisplayName returns the actual translation or the default 505 // uloc_getDisplayName returns the actual translation or the default
506 // value (locale code), we have to rely on this hack to tell whether 506 // value (locale code), we have to rely on this hack to tell whether
507 // the translation is available or not. If ICU doesn't have a translated 507 // the translation is available or not. If ICU doesn't have a translated
508 // name for this locale, GetDisplayNameForLocale will just return the 508 // name for this locale, GetDisplayNameForLocale will just return the
509 // locale code. 509 // locale code.
510 return !IsStringASCII(display_name) || UTF16ToASCII(display_name) != locale; 510 return !IsStringASCII(display_name) ||
511 base::UTF16ToASCII(display_name) != locale;
511 } 512 }
512 513
513 base::string16 GetDisplayNameForLocale(const std::string& locale, 514 base::string16 GetDisplayNameForLocale(const std::string& locale,
514 const std::string& display_locale, 515 const std::string& display_locale,
515 bool is_for_ui) { 516 bool is_for_ui) {
516 std::string locale_code = locale; 517 std::string locale_code = locale;
517 // Internally, we use the language code of zh-CN and zh-TW, but we want the 518 // Internally, we use the language code of zh-CN and zh-TW, but we want the
518 // display names to be Chinese (Simplified) and Chinese (Traditional) instead 519 // display names to be Chinese (Simplified) and Chinese (Traditional) instead
519 // of Chinese (China) and Chinese (Taiwan). To do that, we pass zh-Hans 520 // of Chinese (China) and Chinese (Taiwan). To do that, we pass zh-Hans
520 // and zh-Hant to ICU. Even with this mapping, we'd get 521 // and zh-Hant to ICU. Even with this mapping, we'd get
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 } 882 }
882 883
883 int GetLocalizedContentsWidthInPixels(int pixel_resource_id) { 884 int GetLocalizedContentsWidthInPixels(int pixel_resource_id) {
884 int width = 0; 885 int width = 0;
885 base::StringToInt(l10n_util::GetStringUTF8(pixel_resource_id), &width); 886 base::StringToInt(l10n_util::GetStringUTF8(pixel_resource_id), &width);
886 DCHECK_GT(width, 0); 887 DCHECK_GT(width, 0);
887 return width; 888 return width;
888 } 889 }
889 890
890 } // namespace l10n_util 891 } // namespace l10n_util
OLDNEW
« no previous file with comments | « skia/ext/vector_canvas_unittest.cc ('k') | ui/base/l10n/l10n_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698