Chromium Code Reviews| Index: base/strings/string_util.cc |
| diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc |
| index 725d86da8ac7c64693f566c0fdb7b9cd23968b44..4b5b7a6b35c0b9e11ab4c9899949f4cce9374af5 100644 |
| --- a/base/strings/string_util.cc |
| +++ b/base/strings/string_util.cc |
| @@ -148,6 +148,40 @@ bool IsWprintfFormatPortable(const wchar_t* format) { |
| return true; |
| } |
| +template<typename StringType> |
| +StringType ToLowerASCIIT(BasicStringPiece<StringType> str) { |
|
yzshen1
2015/08/06 18:07:19
Please consider putting this and ToUpperASCIIT int
brettw
2015/08/06 18:23:03
Done, used "Impl"
|
| + StringType ret; |
| + ret.reserve(str.size()); |
| + for (size_t i = 0; i < str.size(); i++) |
| + ret.push_back(ToLowerASCII(str[i])); |
| + return ret; |
| +} |
| + |
| +std::string ToLowerASCII(StringPiece str) { |
| + return ToLowerASCIIT<std::string>(str); |
| +} |
| + |
| +string16 ToLowerASCII(StringPiece16 str) { |
| + return ToLowerASCIIT<string16>(str); |
| +} |
| + |
| +template<typename StringType> |
| +StringType ToUpperASCIIT(BasicStringPiece<StringType> str) { |
| + StringType ret; |
| + ret.reserve(str.size()); |
| + for (size_t i = 0; i < str.size(); i++) |
| + ret.push_back(ToUpperASCII(str[i])); |
| + return ret; |
| +} |
| + |
| +std::string ToUpperASCII(StringPiece str) { |
| + return ToUpperASCIIT<std::string>(str); |
| +} |
| + |
| +string16 ToUpperASCII(StringPiece16 str) { |
| + return ToUpperASCIIT<string16>(str); |
| +} |
| + |
| template<class StringType> |
| int CompareCaseInsensitiveASCIIT(BasicStringPiece<StringType> a, |
| BasicStringPiece<StringType> b) { |