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 <ctime> | |
19 #include <string> | |
20 #include <vector> | |
21 | |
22 namespace i18n { | |
23 namespace addressinput { | |
24 | |
25 // Removes the language variation from |language_code|, unless the variation is | |
26 // "latn". For example, returns "zh" for "zh-hans". Returns "zh-latn" for | |
27 // "zh-latn". | |
28 std::string NormalizeLanguageCode(const std::string& language_code); | |
29 | |
30 // Returns |time| serialized into a string. | |
31 std::string TimeToString(time_t time); | |
32 | |
33 // Unicode (UTF-8) approximate string comparison. Designed for matching user | |
34 // input against canonical data. Returns true for a match. | |
35 bool LooseStringCompare(const std::string& a, const std::string& b); | |
36 | |
37 // Splits |str| into a vector of strings delimited by |c|, placing the results | |
38 // in |r|. If several instances of |c| are contiguous, or if |str| begins with | |
39 // or ends with |c|, then an empty string is inserted. | |
40 // | |
41 // |str| should not be in a multi-byte encoding like Shift-JIS or GBK in which | |
42 // the trailing byte of a multi-byte character can be in the ASCII range. | |
43 // UTF-8, and other single/multi-byte ASCII-compatible encodings are OK. | |
44 // Note: |c| must be in the ASCII range. | |
45 // | |
46 // The original source code is from: | |
47 // http://src.chromium.org/viewvc/chrome/trunk/src/base/strings/string_split.h?r
evision=236210 | |
48 // | |
49 // Modifications from original: | |
50 // 1) Supports only std::string type. | |
51 // 2) Does not trim whitespace. | |
52 void SplitString(const std::string& str, char c, std::vector<std::string>* r); | |
53 | |
54 } // namespace addressinput | |
55 } // namespace i18n | |
56 | |
57 #endif // I18N_ADDRESSINPUT_UTIL_STRING_UTIL_H_ | |
OLD | NEW |