diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-14 16:51:21 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-14 16:51:21 +0000 |
commit | d92224288027cefbbd197bd9eed9080110aa9222 (patch) | |
tree | dde9e6e5f8344cf88196b3d8db6af9c5bdb6f7e1 /chrome/common | |
parent | d41e5c6e49d59d0cf4495c57f29d925ab1a4aa59 (diff) | |
download | chromium_src-d92224288027cefbbd197bd9eed9080110aa9222.zip chromium_src-d92224288027cefbbd197bd9eed9080110aa9222.tar.gz chromium_src-d92224288027cefbbd197bd9eed9080110aa9222.tar.bz2 |
Convert the internal GetStringF to use string16. This saves a
conversion from string16 to wstring on the linux side when
calling GetStringFUTF8 methods.
It actually adds extra conversions when calling GetStringF, but
we're going to get rid of all those, right?
BUG=9911
Review URL: http://codereview.chromium.org/67112
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13666 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/l10n_util.cc | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/chrome/common/l10n_util.cc b/chrome/common/l10n_util.cc index fabd01c..cdb65d7 100644 --- a/chrome/common/l10n_util.cc +++ b/chrome/common/l10n_util.cc @@ -301,79 +301,76 @@ std::string GetStringUTF8(int message_id) { return WideToUTF8(GetString(message_id)); } -static std::wstring GetStringF(int message_id, - const std::wstring& a, - const std::wstring& b, - const std::wstring& c, - const std::wstring& d, - std::vector<size_t>* offsets) { - const std::wstring& format_string = GetString(message_id); - std::wstring formatted = ReplaceStringPlaceholders(format_string, a, b, c, - d, offsets); +static string16 GetStringF(int message_id, + const string16& a, + const string16& b, + const string16& c, + const string16& d, + std::vector<size_t>* offsets) { + // TODO(tc): ResourceBundle::GetLocalizedString should return a string16 + // so we can avoid this conversion on linux/mac. + const string16& format_string = WideToUTF16(GetString(message_id)); + string16 formatted = ReplaceStringPlaceholders(format_string, a, b, c, d, + offsets); return formatted; } -std::wstring GetStringF(int message_id, - const std::wstring& a) { - return GetStringF(message_id, a, std::wstring(), std::wstring(), - std::wstring(), NULL); +std::wstring GetStringF(int message_id, const std::wstring& a) { + return UTF16ToWide(GetStringF(message_id, WideToUTF16(a), string16(), + string16(), string16(), NULL)); } std::wstring GetStringF(int message_id, const std::wstring& a, const std::wstring& b) { - return GetStringF(message_id, a, b, std::wstring(), std::wstring(), NULL); + return UTF16ToWide(GetStringF(message_id, WideToUTF16(a), WideToUTF16(b), + string16(), string16(), NULL)); } std::wstring GetStringF(int message_id, const std::wstring& a, const std::wstring& b, const std::wstring& c) { - return GetStringF(message_id, a, b, c, std::wstring(), NULL); + return UTF16ToWide(GetStringF(message_id, WideToUTF16(a), WideToUTF16(b), + WideToUTF16(c), string16(), NULL)); } std::string GetStringFUTF8(int message_id, const string16& a) { - // TODO(tc): Once this whole file uses string16, we can drop the UTF16ToWide - // conversions. http://crbug.com/9911 - return WideToUTF8(GetStringF(message_id, UTF16ToWide(a))); + return UTF16ToUTF8(GetStringF(message_id, a, string16(), string16(), + string16(), NULL)); } std::string GetStringFUTF8(int message_id, const string16& a, const string16& b) { - // TODO(tc): Once this whole file uses string16, we can drop the UTF16ToWide - // conversions. http://crbug.com/9911 - return WideToUTF8(GetStringF(message_id, UTF16ToWide(a), UTF16ToWide(b))); + return UTF16ToUTF8(GetStringF(message_id, a, b, string16(), string16(), + NULL)); } std::string GetStringFUTF8(int message_id, const string16& a, const string16& b, const string16& c) { - // TODO(tc): Once this whole file uses string16, we can drop the UTF16ToWide - // conversions. http://crbug.com/9911 - return WideToUTF8(GetStringF(message_id, UTF16ToWide(a), UTF16ToWide(b), - UTF16ToWide(c))); + return UTF16ToUTF8(GetStringF(message_id, a, b, c, string16(), NULL)); } -std::wstring GetStringF(int message_id, - const std::wstring& a, - size_t* offset) { +std::wstring GetStringF(int message_id, const std::wstring& a, size_t* offset) { DCHECK(offset); std::vector<size_t> offsets; - std::wstring result = GetStringF(message_id, a, std::wstring(), - std::wstring(), std::wstring(), &offsets); + string16 result = GetStringF(message_id, WideToUTF16(a), string16(), + string16(), string16(), &offsets); DCHECK(offsets.size() == 1); *offset = offsets[0]; - return result; + return UTF16ToWide(result); } std::wstring GetStringF(int message_id, const std::wstring& a, const std::wstring& b, std::vector<size_t>* offsets) { - return GetStringF(message_id, a, b, std::wstring(), std::wstring(), offsets); + return UTF16ToWide(GetStringF(message_id, WideToUTF16(a), WideToUTF16(b), + string16(), string16(), offsets)); } std::wstring GetStringF(int message_id, int a) { |