Ignore:
Timestamp:
Mar 6, 2008, 9:50:08 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Darin.

<rdar://problem/5687269> Need to create a Collator abstraction for WebCore and JavaScriptCore

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/string_object.cpp

    r30534 r30842  
    3131#include "regexp_object.h"
    3232#include <wtf/MathExtras.h>
    33 #include <wtf/unicode/Unicode.h>
    34 
    35 #if PLATFORM(CF)
    36 #include <CoreFoundation/CoreFoundation.h>
    37 #elif PLATFORM(WIN_OS)
    38 #include <windows.h>
    39 #endif
     33#include <wtf/unicode/Collator.h>
    4034
    4135using namespace WTF;
     
    295289  return substitutedReplacement;
    296290}
     291
    297292static inline int localeCompare(const UString& a, const UString& b)
    298293{
    299 #if PLATFORM(WIN_OS)
    300     int retval = CompareStringW(LOCALE_USER_DEFAULT, 0,
    301                                 reinterpret_cast<LPCWSTR>(a.data()), a.size(),
    302                                 reinterpret_cast<LPCWSTR>(b.data()), b.size());
    303     return !retval ? retval : retval - 2;
    304 #elif PLATFORM(CF)
    305     CFStringRef sa = CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, reinterpret_cast<const UniChar*>(a.data()), a.size(), kCFAllocatorNull);
    306     CFStringRef sb = CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, reinterpret_cast<const UniChar*>(b.data()), b.size(), kCFAllocatorNull);
    307 
    308     int retval = CFStringCompare(sa, sb, kCFCompareLocalized);
    309 
    310     CFRelease(sa);
    311     CFRelease(sb);
    312 
    313     return retval;
    314 #else
    315     return compare(a, b);
    316 #endif
     294    return Collator::userDefault()->collate(reinterpret_cast<const ::UChar*>(a.data()), a.size(), reinterpret_cast<const ::UChar*>(b.data()), b.size());
    317295}
    318296
Note: See TracChangeset for help on using the changeset viewer.