1*635a8641SAndroid Build Coastguard Worker // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2*635a8641SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*635a8641SAndroid Build Coastguard Worker // found in the LICENSE file.
4*635a8641SAndroid Build Coastguard Worker
5*635a8641SAndroid Build Coastguard Worker #include "base/i18n/string_compare.h"
6*635a8641SAndroid Build Coastguard Worker
7*635a8641SAndroid Build Coastguard Worker #include "base/logging.h"
8*635a8641SAndroid Build Coastguard Worker #include "base/strings/utf_string_conversions.h"
9*635a8641SAndroid Build Coastguard Worker #include "third_party/icu/source/common/unicode/unistr.h"
10*635a8641SAndroid Build Coastguard Worker
11*635a8641SAndroid Build Coastguard Worker namespace base {
12*635a8641SAndroid Build Coastguard Worker namespace i18n {
13*635a8641SAndroid Build Coastguard Worker
14*635a8641SAndroid Build Coastguard Worker // Compares the character data stored in two different string16 strings by
15*635a8641SAndroid Build Coastguard Worker // specified Collator instance.
CompareString16WithCollator(const icu::Collator & collator,const string16 & lhs,const string16 & rhs)16*635a8641SAndroid Build Coastguard Worker UCollationResult CompareString16WithCollator(const icu::Collator& collator,
17*635a8641SAndroid Build Coastguard Worker const string16& lhs,
18*635a8641SAndroid Build Coastguard Worker const string16& rhs) {
19*635a8641SAndroid Build Coastguard Worker UErrorCode error = U_ZERO_ERROR;
20*635a8641SAndroid Build Coastguard Worker UCollationResult result = collator.compare(
21*635a8641SAndroid Build Coastguard Worker icu::UnicodeString(FALSE, lhs.c_str(), static_cast<int>(lhs.length())),
22*635a8641SAndroid Build Coastguard Worker icu::UnicodeString(FALSE, rhs.c_str(), static_cast<int>(rhs.length())),
23*635a8641SAndroid Build Coastguard Worker error);
24*635a8641SAndroid Build Coastguard Worker DCHECK(U_SUCCESS(error));
25*635a8641SAndroid Build Coastguard Worker return result;
26*635a8641SAndroid Build Coastguard Worker }
27*635a8641SAndroid Build Coastguard Worker
28*635a8641SAndroid Build Coastguard Worker } // namespace i18n
29*635a8641SAndroid Build Coastguard Worker } // namespace base
30