diff options
author | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 10:02:52 +0000 |
---|---|---|
committer | hbono@chromium.org <hbono@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 10:02:52 +0000 |
commit | 0676a96af598e97e3b6016cd3675e2f424dc8407 (patch) | |
tree | 5ff6d221bdbbc1bba12a5b41f160fd68e2ef453a /base/string_util.h | |
parent | 503683f23ea6fe3eb728f2d09f81f2603ffc7d6f (diff) | |
download | chromium_src-0676a96af598e97e3b6016cd3675e2f424dc8407.zip chromium_src-0676a96af598e97e3b6016cd3675e2f424dc8407.tar.gz chromium_src-0676a96af598e97e3b6016cd3675e2f424dc8407.tar.bz2 |
Fixes Issue 7377: Regression: Omnibox trims URL ending with 0x85
To fix this issue, this change adds a new function TrimWhitespaceUTF8(), which trims space characters (including non-printable characters and broken UTF-8 characters) from either end of a UTF-8 string.
Please feel free to give me your comments since I'm not sure this implimentation is correct. (Maybe this implementation trims too aggressively.)
BUG=7377
Review URL: http://codereview.chromium.org/20219
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10456 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util.h')
-rw-r--r-- | base/string_util.h | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/base/string_util.h b/base/string_util.h index 500a114..64e724e 100644 --- a/base/string_util.h +++ b/base/string_util.h @@ -128,9 +128,13 @@ bool TrimString(const std::string& input, std::string* output); // Trims any whitespace from either end of the input string. Returns where -// whitespace was found. The non-wide version of this function only looks for -// ASCII whitespace; UTF-8 code-points are not searched for (use the wide -// version instead). +// whitespace was found. +// The non-wide version has two functions: +// * TrimWhitespaceASCII() +// This function is for ASCII strings and only looks for ASCII whitespace; +// * TrimWhitespaceUTF8() +// This function is for UTF-8 strings and looks for Unicode whitespace. +// Please choose the best one according to your usage. // NOTE: Safe to use the same variable for both input and output. enum TrimPositions { TRIM_NONE = 0, @@ -141,6 +145,15 @@ enum TrimPositions { TrimPositions TrimWhitespace(const std::wstring& input, TrimPositions positions, std::wstring* output); +TrimPositions TrimWhitespaceASCII(const std::string& input, + TrimPositions positions, + std::string* output); +TrimPositions TrimWhitespaceUTF8(const std::string& input, + TrimPositions positions, + std::string* output); + +// Deprecated. This function is only for backward compatibility and calls +// TrimWhitespaceASCII(). TrimPositions TrimWhitespace(const std::string& input, TrimPositions positions, std::string* output); |