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

Unified Diff: base/string_util.h

Issue 9509: Make unit_tests pass with pt_BR.UTF-8 locale. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 12 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/json_writer.cc ('k') | base/string_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/string_util.h
===================================================================
--- base/string_util.h (revision 5165)
+++ base/string_util.h (working copy)
@@ -127,6 +127,14 @@
// Names of codepages (charsets) understood by icu.
extern const char* const kCodepageUTF8;
+// When some function takes an optional parameter to control locale
+// independence, you should use values from here to make function call
+// look more descriptive.
+enum LocaleDependence {
+ LOCALE_DEPENDENT = true,
+ LOCALE_INDEPENDENT = false
+};
+
// Removes characters in trim_chars from the beginning and end of input.
// NOTE: Safe to use the same variable for both input and output.
bool TrimString(const std::wstring& input,
@@ -354,6 +362,9 @@
std::string Uint64ToString(uint64 value);
std::wstring Uint64ToWString(uint64 value);
+std::string DoubleToString(double value, LocaleDependence locale_dependent);
+std::wstring DoubleToWString(double value, LocaleDependence locale_dependent);
+
// 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:
@@ -376,8 +387,14 @@
// 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.
+//
+// By default, locale-dependent variant is used.
bool StringToDouble(const std::string& input, double* output);
+bool StringToDouble(const std::string& input, double* output,
+ LocaleDependence locale_dependent);
bool StringToDouble(const std::wstring& input, double* output);
+bool StringToDouble(const std::wstring& input, double* output,
+ LocaleDependence locale_dependent);
// Convenience forms of the above, when the caller is uninterested in the
// boolean return value. These return only the |*output| value from the
@@ -388,8 +405,13 @@
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::string& value,
+ LocaleDependence locale_dependent);
double StringToDouble(const std::wstring& value);
+double StringToDouble(const std::wstring& value,
+ LocaleDependence locale_dependent);
// Return a C++ string given printf-like input.
std::string StringPrintf(const char* format, ...);
« no previous file with comments | « base/json_writer.cc ('k') | base/string_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698