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