int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) const { if (d->dirty) d->init(); SInt32 result; Boolean equivalent; UCCompareText(d->collator, reinterpret_cast<const UniChar *>(s1), len1, reinterpret_cast<const UniChar *>(s2), len2, &equivalent, &result); if (equivalent) return 0; return result < 0 ? -1 : 1; }
int MacOSUnicodeConverter::compareNIString( const XMLCh* const comp1 , const XMLCh* const comp2 , const XMLSize_t maxChars) { // If unicode collation routines are available, use them. // This should be the case on Mac OS 8.6 and later, // with Carbon 1.0.2 or later, and under Mac OS X. // // Otherwise, but only for Metrowerks, since only Metrowerks // has a c library with a valid set of wchar routines, // fall back to the standard library. if (fHasUnicodeCollation && fCollator != NULL) { std::size_t cnt1 = XMLString::stringLen(comp1); std::size_t cnt2 = XMLString::stringLen(comp2); // Restrict view of source characters to first {maxChars} if (cnt1 > maxChars) cnt1 = maxChars; if (cnt2 > maxChars) cnt2 = maxChars; Boolean equivalent = false; SInt32 order = 0; OSStatus status = UCCompareText( fCollator, reinterpret_cast<const UniChar*>(comp1), cnt1, reinterpret_cast<const UniChar*>(comp2), cnt2, &equivalent, &order ); return ((status != noErr) || equivalent) ? 0 : order; } else { // For some reason there is no platform utils available // where we expect it. Bail. XMLPlatformUtils::panic(PanicHandler::Panic_NoTransService); return 0; } }