Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2983)

Unified Diff: chrome/common/l10n_util.cc

Issue 20484: Adds a method to sort the elements of a vector by invoking a method on... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/l10n_util.h ('k') | chrome/common/l10n_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/l10n_util.cc
===================================================================
--- chrome/common/l10n_util.cc (revision 10251)
+++ chrome/common/l10n_util.cc (working copy)
@@ -25,8 +25,6 @@
#if defined(OS_WIN)
#include "chrome/views/view.h"
#endif // defined(OS_WIN)
-#include "unicode/rbbi.h"
-#include "unicode/uchar.h"
// TODO(playmobil): remove this undef once SkPostConfig.h is fixed.
// skia/include/corecg/SkPostConfig.h #defines strcasecmp() so we can't use
@@ -210,35 +208,6 @@
return ASCIIToWide(ret);
}
-// Compares the character data stored in two different strings by specified
-// Collator instance.
-UCollationResult CompareStringWithCollator(const Collator* collator,
- const std::wstring& lhs,
- const std::wstring& rhs) {
- DCHECK(collator);
- UErrorCode error = U_ZERO_ERROR;
-#if defined(WCHAR_T_IS_UTF32)
- // Need to convert to UTF-16 to be compatible with UnicodeString's
- // constructor.
- string16 lhs_utf16 = WideToUTF16(lhs);
- string16 rhs_utf16 = WideToUTF16(rhs);
-
- UCollationResult result = collator->compare(
- static_cast<const UChar*>(lhs_utf16.c_str()),
- static_cast<int>(lhs_utf16.length()),
- static_cast<const UChar*>(rhs_utf16.c_str()),
- static_cast<int>(rhs_utf16.length()),
- error);
-#else
- UCollationResult result = collator->compare(
- static_cast<const UChar*>(lhs.c_str()), static_cast<int>(lhs.length()),
- static_cast<const UChar*>(rhs.c_str()), static_cast<int>(rhs.length()),
- error);
-#endif
- DCHECK(U_SUCCESS(error));
- return result;
-}
-
} // namespace
namespace l10n_util {
@@ -671,6 +640,35 @@
}
#endif // defined(OS_WIN)
+// Compares the character data stored in two different strings by specified
+// Collator instance.
+UCollationResult CompareStringWithCollator(const Collator* collator,
+ const std::wstring& lhs,
+ const std::wstring& rhs) {
+ DCHECK(collator);
+ UErrorCode error = U_ZERO_ERROR;
+#if defined(WCHAR_T_IS_UTF32)
+ // Need to convert to UTF-16 to be compatible with UnicodeString's
+ // constructor.
+ string16 lhs_utf16 = WideToUTF16(lhs);
+ string16 rhs_utf16 = WideToUTF16(rhs);
+
+ UCollationResult result = collator->compare(
+ static_cast<const UChar*>(lhs_utf16.c_str()),
+ static_cast<int>(lhs_utf16.length()),
+ static_cast<const UChar*>(rhs_utf16.c_str()),
+ static_cast<int>(rhs_utf16.length()),
+ error);
+#else
+ UCollationResult result = collator->compare(
+ static_cast<const UChar*>(lhs.c_str()), static_cast<int>(lhs.length()),
+ static_cast<const UChar*>(rhs.c_str()), static_cast<int>(rhs.length()),
+ error);
+#endif
+ DCHECK(U_SUCCESS(error));
+ return result;
+}
+
// Specialization of operator() method for std::wstring version.
template <>
bool StringComparator<std::wstring>::operator()(const std::wstring& lhs,
« no previous file with comments | « chrome/common/l10n_util.h ('k') | chrome/common/l10n_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698