diff options
author | nick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-28 20:18:20 +0000 |
---|---|---|
committer | nick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-28 20:18:20 +0000 |
commit | d06e3e078e734adbb98909f871e510eddcdd54a5 (patch) | |
tree | 8fc0b814307a9dec0e157d902a4bb6d442a02fb3 /base/string_util.h | |
parent | d87f845659b2e54622850acfc780b7fc07cfed6c (diff) | |
download | chromium_src-d06e3e078e734adbb98909f871e510eddcdd54a5.zip chromium_src-d06e3e078e734adbb98909f871e510eddcdd54a5.tar.gz chromium_src-d06e3e078e734adbb98909f871e510eddcdd54a5.tar.bz2 |
Add a method that truncates strings to the end point of a valid UTF8 character, leaving the string's size to be less than or equal to a specified byte size.
BUG=43675
TEST=base/string_util_unittest.cc
Patch contributed by to Jerrica Jones (jerrica@chromium.org).
Review URL: http://codereview.chromium.org/2239007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48518 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util.h')
-rw-r--r-- | base/string_util.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/base/string_util.h b/base/string_util.h index 28cd26f..cb7e5b5 100644 --- a/base/string_util.h +++ b/base/string_util.h @@ -164,6 +164,12 @@ bool TrimString(const std::string& input, const char trim_chars[], std::string* output); +// Truncates a string to the nearest UTF-8 character that will leave +// the string less than or equal to the specified byte size. +void TruncateUTF8ToByteSize(const std::string& input, + const size_t byte_size, + std::string* output); + // Trims any whitespace from either end of the input string. Returns where // whitespace was found. // The non-wide version has two functions: |