OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cpp/src/util/canonicalize_string.h" | 5 #include "cpp/src/util/canonicalize_string.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "cpp/include/libaddressinput/util/scoped_ptr.h" | 8 #include "cpp/include/libaddressinput/util/scoped_ptr.h" |
| 9 #include "third_party/icu/source/common/unicode/errorcode.h" |
| 10 #include "third_party/icu/source/common/unicode/locid.h" |
| 11 #include "third_party/icu/source/common/unicode/unistr.h" |
| 12 #include "third_party/icu/source/common/unicode/utypes.h" |
9 #include "third_party/icu/source/i18n/unicode/coll.h" | 13 #include "third_party/icu/source/i18n/unicode/coll.h" |
10 | 14 |
11 namespace i18n { | 15 namespace i18n { |
12 namespace addressinput { | 16 namespace addressinput { |
13 | 17 |
14 namespace { | 18 namespace { |
15 | 19 |
16 class ChromeStringCanonicalizer : public StringCanonicalizer { | 20 class ChromeStringCanonicalizer : public StringCanonicalizer { |
17 public: | 21 public: |
18 ChromeStringCanonicalizer() | 22 ChromeStringCanonicalizer() |
19 : error_code_(U_ZERO_ERROR), | 23 : error_code_(U_ZERO_ERROR), |
20 collator_(icu::Collator::createInstance(error_code_)) { | 24 collator_( |
| 25 icu::Collator::createInstance( |
| 26 icu::Locale::getRoot(), error_code_)) { |
21 collator_->setStrength(icu::Collator::PRIMARY); | 27 collator_->setStrength(icu::Collator::PRIMARY); |
22 DCHECK(U_SUCCESS(error_code_)); | 28 DCHECK(U_SUCCESS(error_code_)); |
23 } | 29 } |
24 | 30 |
25 virtual ~ChromeStringCanonicalizer() {} | 31 virtual ~ChromeStringCanonicalizer() {} |
26 | 32 |
27 // StringCanonicalizer implementation. | 33 // StringCanonicalizer implementation. |
28 virtual std::string CanonicalizeString(const std::string& original) { | 34 virtual std::string CanonicalizeString(const std::string& original) { |
29 // Returns a canonical version of the string that can be used for comparing | 35 // Returns a canonical version of the string that can be used for comparing |
30 // strings regardless of diacritics and capitalization. | 36 // strings regardless of diacritics and capitalization. |
(...skipping 23 matching lines...) Expand all Loading... |
54 | 60 |
55 } // namespace | 61 } // namespace |
56 | 62 |
57 // static | 63 // static |
58 scoped_ptr<StringCanonicalizer> StringCanonicalizer::Build() { | 64 scoped_ptr<StringCanonicalizer> StringCanonicalizer::Build() { |
59 return scoped_ptr<StringCanonicalizer>(new ChromeStringCanonicalizer); | 65 return scoped_ptr<StringCanonicalizer>(new ChromeStringCanonicalizer); |
60 } | 66 } |
61 | 67 |
62 } // namespace addressinput | 68 } // namespace addressinput |
63 } // namespace i18n | 69 } // namespace i18n |
OLD | NEW |