summaryrefslogtreecommitdiffstats
path: root/base/string_util.h
diff options
context:
space:
mode:
authortc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-12 23:19:30 +0000
committertc@google.com <tc@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-12 23:19:30 +0000
commit4f2ad3f5ab8550a404d4c70c29938c19110b3ecb (patch)
treeca8af381337293f5a3b1221b6e5a53849af02450 /base/string_util.h
parentb377d9cd5c2a3e723dd55b797f52de8d2d41a032 (diff)
downloadchromium_src-4f2ad3f5ab8550a404d4c70c29938c19110b3ecb.zip
chromium_src-4f2ad3f5ab8550a404d4c70c29938c19110b3ecb.tar.gz
chromium_src-4f2ad3f5ab8550a404d4c70c29938c19110b3ecb.tar.bz2
Make unit_tests pass with pt_BR.UTF-8 locale.
BUG=3675 Patch from Paweł Hajdan jr <phajdan.jr@gmail.com> original issue: http://codereview.chromium.org/9509 Review URL: http://codereview.chromium.org/11002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5319 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util.h')
-rw-r--r--base/string_util.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/base/string_util.h b/base/string_util.h
index d62e9b0..488d4a2 100644
--- a/base/string_util.h
+++ b/base/string_util.h
@@ -95,6 +95,23 @@ size_t wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size);
// This function is intended to be called from base::vswprintf.
bool IsWprintfFormatPortable(const wchar_t* format);
+enum LocaleDependence {
+ LOCALE_DEPENDENT,
+ LOCALE_INDEPENDENT
+};
+
+std::string DoubleToString(double value, LocaleDependence locale_dependent);
+std::wstring DoubleToWString(double value, LocaleDependence locale_dependent);
+
+bool StringToDouble(const std::string& input, double* output,
+ LocaleDependence locale_dependent);
+bool StringToDouble(const std::wstring& input, double* output,
+ LocaleDependence locale_dependent);
+double StringToDouble(const std::string& value,
+ LocaleDependence locale_dependent);
+double StringToDouble(const std::wstring& value,
+ LocaleDependence locale_dependent);
+
} // namespace base
#if defined(OS_WIN)
@@ -354,6 +371,7 @@ std::wstring Int64ToWString(int64 value);
std::string Uint64ToString(uint64 value);
std::wstring Uint64ToWString(uint64 value);
+
// Perform a best-effort conversion of the input string to a numeric type,
// setting |*output| to the result of the conversion. Returns true for
// "perfect" conversions; returns false in the following cases:
@@ -375,7 +393,7 @@ bool HexStringToInt(const std::wstring& input, int* output);
// form are defined to work. Behavior with strings representing floating-point
// numbers in hexadecimal, and strings representing non-fininte values (such
// as NaN and inf) is undefined. Otherwise, these behave the same as the
-// integral variants above.
+// integral variants above. By default, locale-dependent variant is used.
bool StringToDouble(const std::string& input, double* output);
bool StringToDouble(const std::wstring& input, double* output);
@@ -388,6 +406,7 @@ int64 StringToInt64(const std::string& value);
int64 StringToInt64(const std::wstring& value);
int HexStringToInt(const std::string& value);
int HexStringToInt(const std::wstring& value);
+// By default, locale-dependent variant is used.
double StringToDouble(const std::string& value);
double StringToDouble(const std::wstring& value);