1818#include "CFString_Internal.h"
1919#include <limits.h>
2020#include <stdlib.h>
21- #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX
21+ #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_WASI
2222#include <unicode/ucol.h>
2323#include <unicode/ucoleitr.h>
2424#endif
@@ -111,7 +111,7 @@ CFStringEncoding CFStringConvertIANACharSetNameToEncoding(CFStringRef charsetNam
111111
112112 encoding = __CFStringEncodingGetFromCanonicalName (name );
113113
114- #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX
114+ #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_WASI
115115 if (kCFStringEncodingInvalidId == encoding ) encoding = __CFStringEncodingGetFromICUName (name );
116116#endif
117117
@@ -262,7 +262,7 @@ CFStringEncoding CFStringGetMostCompatibleMacStringEncoding(CFStringEncoding enc
262262
263263#define kCFStringCompareAllocationIncrement (128)
264264
265- #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX
265+ #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_WASI
266266
267267// -------------------------------------------------------------------------------------------------
268268// CompareSpecials - ignore case & diacritic differences
@@ -425,7 +425,7 @@ static UCollator *__CFStringCopyDefaultCollator(CFLocaleRef compareLocale) {
425425 return collator ;
426426}
427427
428- #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX
428+ #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_WASI
429429static void __collatorFinalize (UCollator * collator ) {
430430 CFLocaleRef locale = _CFGetTSD (__CFTSDKeyCollatorLocale );
431431 _CFSetTSD (__CFTSDKeyCollatorUCollator , NULL , NULL );
@@ -578,7 +578,7 @@ CF_PRIVATE CFComparisonResult _CFCompareStringsWithLocale(CFStringInlineBuffer *
578578 CFRange range1 = str1Range ;
579579 CFRange range2 = str2Range ;
580580 SInt32 order ;
581- #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX
581+ #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_WASI
582582 Boolean isEqual ;
583583 bool forcedOrdering = ((options & kCFCompareForcedOrdering ) ? true : false);
584584
@@ -611,7 +611,7 @@ CF_PRIVATE CFComparisonResult _CFCompareStringsWithLocale(CFStringInlineBuffer *
611611 range2 .location = __extendLocationBackward (range2 .location - 1 , str2 , nonBaseBMP , punctBMP );
612612 }
613613
614- #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX
614+ #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_WASI
615615 // First we try to use the last one used on this thread, if the locale is the same,
616616 // otherwise we try to check out a default one, or then we create one.
617617 UCollator * threadCollator = _CFGetTSD (__CFTSDKeyCollatorUCollator );
@@ -633,7 +633,7 @@ CF_PRIVATE CFComparisonResult _CFCompareStringsWithLocale(CFStringInlineBuffer *
633633 range1 .length = (str1Range .location + str1Range .length ) - range1 .location ;
634634 range2 .length = (str2Range .location + str2Range .length ) - range2 .location ;
635635
636- #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX
636+ #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_WASI
637637 if ((NULL != collator ) && (__CompareTextDefault (collator , options , characters1 , range1 .length , characters2 , range2 .length , & isEqual , & order ) == 0 /* noErr */ )) {
638638 compResult = ((isEqual && !forcedOrdering ) ? kCFCompareEqualTo : ((order < 0 ) ? kCFCompareLessThan : kCFCompareGreaterThan ));
639639 } else
@@ -709,7 +709,7 @@ CF_PRIVATE CFComparisonResult _CFCompareStringsWithLocale(CFStringInlineBuffer *
709709 }
710710 }
711711
712- #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX
712+ #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_WASI
713713 if ((NULL != collator ) && (__CompareTextDefault (collator , options , characters1 , range1 .length , characters2 , range2 .length , & isEqual , & order ) == 0 /* noErr */ )) {
714714 if (isEqual ) {
715715 if (forcedOrdering && (kCFCompareEqualTo == compResult ) && (0 != order )) compResult = ((order < 0 ) ? kCFCompareLessThan : kCFCompareGreaterThan );
@@ -753,7 +753,7 @@ CF_PRIVATE CFComparisonResult _CFCompareStringsWithLocale(CFStringInlineBuffer *
753753 if (buffer2Len > 0 ) CFAllocatorDeallocate (kCFAllocatorSystemDefault , buffer2 );
754754 }
755755
756- #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX
756+ #if TARGET_OS_MAC || TARGET_OS_WIN32 || TARGET_OS_LINUX || TARGET_OS_WASI
757757 if (collator == threadCollator ) {
758758 // do nothing, already cached
759759 } else {
0 commit comments