summaryrefslogtreecommitdiffstats
path: root/base/string_util.cc
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-18 21:30:36 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-18 21:30:36 +0000
commit016d78de3eb0ee784728c99836cb42753e8dea60 (patch)
tree398679128dd10491063194548ae93fb3115fad19 /base/string_util.cc
parent7b0ac2b15ccf3652097cb87d60f34f6bfda6388a (diff)
downloadchromium_src-016d78de3eb0ee784728c99836cb42753e8dea60.zip
chromium_src-016d78de3eb0ee784728c99836cb42753e8dea60.tar.gz
chromium_src-016d78de3eb0ee784728c99836cb42753e8dea60.tar.bz2
Convert FormatBytes to string16.
I considered ASCII, but it's producing what is intended to be a human-readable string. For example, in theory the "bytes/s" annotation could be localized into a language where the "b" is non-ASCII. Review URL: http://codereview.chromium.org/3107021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56603 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util.cc')
-rw-r--r--base/string_util.cc46
1 files changed, 23 insertions, 23 deletions
diff --git a/base/string_util.cc b/base/string_util.cc
index 917d9a9..4dbcd7b 100644
--- a/base/string_util.cc
+++ b/base/string_util.cc
@@ -652,27 +652,27 @@ DataUnits GetByteDisplayUnits(int64 bytes) {
// TODO(mpcomplete): deal with locale
// Byte suffixes. This must match the DataUnits enum.
-static const wchar_t* const kByteStrings[] = {
- L"B",
- L"kB",
- L"MB",
- L"GB"
+static const char* const kByteStrings[] = {
+ "B",
+ "kB",
+ "MB",
+ "GB"
};
-static const wchar_t* const kSpeedStrings[] = {
- L"B/s",
- L"kB/s",
- L"MB/s",
- L"GB/s"
+static const char* const kSpeedStrings[] = {
+ "B/s",
+ "kB/s",
+ "MB/s",
+ "GB/s"
};
-std::wstring FormatBytesInternal(int64 bytes,
- DataUnits units,
- bool show_units,
- const wchar_t* const* suffix) {
+string16 FormatBytesInternal(int64 bytes,
+ DataUnits units,
+ bool show_units,
+ const char* const* suffix) {
if (bytes < 0) {
NOTREACHED() << "Negative bytes value";
- return std::wstring();
+ return string16();
}
DCHECK(units >= DATA_UNITS_BYTE && units <= DATA_UNITS_GIBIBYTE);
@@ -682,26 +682,26 @@ std::wstring FormatBytesInternal(int64 bytes,
for (int i = 0; i < units; ++i)
unit_amount /= 1024.0;
- wchar_t buf[64];
+ char buf[64];
if (bytes != 0 && units != DATA_UNITS_BYTE && unit_amount < 100)
- base::swprintf(buf, arraysize(buf), L"%.1lf", unit_amount);
+ base::snprintf(buf, arraysize(buf), "%.1lf", unit_amount);
else
- base::swprintf(buf, arraysize(buf), L"%.0lf", unit_amount);
+ base::snprintf(buf, arraysize(buf), "%.0lf", unit_amount);
- std::wstring ret(buf);
+ std::string ret(buf);
if (show_units) {
- ret += L" ";
+ ret += " ";
ret += suffix[units];
}
- return ret;
+ return ASCIIToUTF16(ret);
}
-std::wstring FormatBytes(int64 bytes, DataUnits units, bool show_units) {
+string16 FormatBytes(int64 bytes, DataUnits units, bool show_units) {
return FormatBytesInternal(bytes, units, show_units, kByteStrings);
}
-std::wstring FormatSpeed(int64 bytes, DataUnits units, bool show_units) {
+string16 FormatSpeed(int64 bytes, DataUnits units, bool show_units) {
return FormatBytesInternal(bytes, units, show_units, kSpeedStrings);
}