| OLD | NEW |
| (Empty) |
| 1 // Copyright (C) 2014 Google Inc. | |
| 2 // | |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
| 4 // you may not use this file except in compliance with the License. | |
| 5 // You may obtain a copy of the License at | |
| 6 // | |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | |
| 8 // | |
| 9 // Unless required by applicable law or agreed to in writing, software | |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 12 // See the License for the specific language governing permissions and | |
| 13 // limitations under the License. | |
| 14 | |
| 15 #ifndef I18N_ADDRESSINPUT_UTIL_STRING_UTIL_H_ | |
| 16 #define I18N_ADDRESSINPUT_UTIL_STRING_UTIL_H_ | |
| 17 | |
| 18 #include <string> | |
| 19 #include <vector> | |
| 20 | |
| 21 namespace i18n { | |
| 22 namespace addressinput { | |
| 23 | |
| 24 // Removes the language variation from |language_code|, unless the variation is | |
| 25 // "latn". For example, returns "zh" for "zh-hans". Returns "zh-latn" for | |
| 26 // "zh-latn". | |
| 27 std::string NormalizeLanguageCode(const std::string& language_code); | |
| 28 | |
| 29 // Returns |time| serialized into a string. | |
| 30 std::string TimeToString(time_t time); | |
| 31 | |
| 32 // Unicode (UTF-8) approximate string comparison. Designed for matching user | |
| 33 // input against canonical data. Returns true for a match. | |
| 34 bool LooseStringCompare(const std::string& a, const std::string& b); | |
| 35 | |
| 36 // Splits |str| into a vector of strings delimited by |c|, placing the results | |
| 37 // in |r|. If several instances of |c| are contiguous, or if |str| begins with | |
| 38 // or ends with |c|, then an empty string is inserted. | |
| 39 // | |
| 40 // |str| should not be in a multi-byte encoding like Shift-JIS or GBK in which | |
| 41 // the trailing byte of a multi-byte character can be in the ASCII range. | |
| 42 // UTF-8, and other single/multi-byte ASCII-compatible encodings are OK. | |
| 43 // Note: |c| must be in the ASCII range. | |
| 44 // | |
| 45 // The original source code is from: | |
| 46 // http://src.chromium.org/viewvc/chrome/trunk/src/base/strings/string_split.h?r
evision=236210 | |
| 47 // | |
| 48 // Modifications from original: | |
| 49 // 1) Supports only std::string type. | |
| 50 // 2) Does not trim whitespace. | |
| 51 void SplitString(const std::string& str, char c, std::vector<std::string>* r); | |
| 52 | |
| 53 } // namespace addressinput | |
| 54 } // namespace i18n | |
| 55 | |
| 56 #endif // I18N_ADDRESSINPUT_UTIL_STRING_UTIL_H_ | |
| OLD | NEW |