diff options
author | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-09 00:59:47 +0000 |
---|---|---|
committer | tc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-09 00:59:47 +0000 |
commit | b12d1d8a6ff6ea430ccf8c39f6907c2f9cdde97f (patch) | |
tree | 1391fc29a61ca3ec49bcbd9b82fdd570e38a11c5 /chrome/common | |
parent | dbadbccda1ef5744aa78c4666434be9f7622a326 (diff) | |
download | chromium_src-b12d1d8a6ff6ea430ccf8c39f6907c2f9cdde97f.zip chromium_src-b12d1d8a6ff6ea430ccf8c39f6907c2f9cdde97f.tar.gz chromium_src-b12d1d8a6ff6ea430ccf8c39f6907c2f9cdde97f.tar.bz2 |
Add UTF8 versions of GetString and GetStringF. This is useful for
the linux port because GTK expects UTF8.
Review URL: http://codereview.chromium.org/62166
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13397 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/l10n_util.cc | 29 | ||||
-rw-r--r-- | chrome/common/l10n_util.h | 10 |
2 files changed, 39 insertions, 0 deletions
diff --git a/chrome/common/l10n_util.cc b/chrome/common/l10n_util.cc index 8d1a6f3..ed85365 100644 --- a/chrome/common/l10n_util.cc +++ b/chrome/common/l10n_util.cc @@ -297,6 +297,10 @@ std::wstring GetString(int message_id) { return rb.GetLocalizedString(message_id); } +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, @@ -328,6 +332,31 @@ std::wstring GetStringF(int message_id, return GetStringF(message_id, a, b, c, std::wstring(), NULL); } +std::string GetStringFUTF8(int message_id, + const string16& a) { + // TODO(tc): Once this whole file uses string16, we can drop the UTF16ToWide + // conversions. + return WideToUTF8(GetStringF(message_id, UTF16ToWide(a))); +} + +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. + return WideToUTF8(GetStringF(message_id, UTF16ToWide(a), UTF16ToWide(b))); +} + +std::string GetStringF(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. + return WideToUTF8(GetStringF(message_id, UTF16ToWide(a), UTF16ToWide(b), + UTF16ToWide(c))); +} + std::wstring GetStringF(int message_id, const std::wstring& a, size_t* offset) { diff --git a/chrome/common/l10n_util.h b/chrome/common/l10n_util.h index e26fe70..828112c 100644 --- a/chrome/common/l10n_util.h +++ b/chrome/common/l10n_util.h @@ -66,6 +66,7 @@ std::wstring GetLocalName(const std::string& locale_code_str, // Pulls resource string from the string bundle and returns it. std::wstring GetString(int message_id); +std::string GetStringUTF8(int message_id); // Get a resource string and replace $1-$2-$3 with |a| and |b| // respectively. Additionally, $$ is replaced by $. @@ -78,6 +79,15 @@ std::wstring GetStringF(int message_id, const std::wstring& a, const std::wstring& b, const std::wstring& c); +std::string GetStringFUTF8(int message_id, + const string16& a); +std::string GetStringFUTF8(int message_id, + const string16& a, + const string16& b); +std::string GetStringFUTF8(int message_id, + const string16& a, + const string16& b, + const string16& c); // Variants that return the offset(s) of the replaced parameters. The // vector based version returns offsets ordered by parameter. For example if |