mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[string] Add UText shims; NFC
Add ICU shims for creating UTexts and performing grapheme breaking using UTexts. This will allow us to explore multi-encoding grapheme support throughout string.
This commit is contained in:
@@ -25,6 +25,7 @@ extern "C" {
|
||||
|
||||
// Types
|
||||
typedef struct UBreakIterator UBreakIterator;
|
||||
typedef struct UText UText;
|
||||
typedef struct UBreakIterator UNormalizer2;
|
||||
typedef enum UBreakIteratorType {} UBreakIteratorType;
|
||||
typedef enum UErrorCode {} UErrorCode;
|
||||
@@ -40,6 +41,10 @@ UBreakIterator *ubrk_open(UBreakIteratorType, const char *, const UChar *,
|
||||
int32_t ubrk_preceding(UBreakIterator *, int32_t);
|
||||
int32_t ubrk_following(UBreakIterator *, int32_t);
|
||||
void ubrk_setText(UBreakIterator *, const UChar *, int32_t, UErrorCode *);
|
||||
void ubrk_setUText(UBreakIterator *, UText *, UErrorCode *);
|
||||
|
||||
UText *utext_openUTF8(UText *, const char *, int64_t, UErrorCode *);
|
||||
UText *utext_openUChars(UText *, const UChar *, int64_t, UErrorCode *);
|
||||
|
||||
// Comparison, normalization, and character property APIs
|
||||
int32_t unorm2_spanQuickCheckYes(const UNormalizer2 *, const UChar *, int32_t,
|
||||
@@ -164,6 +169,32 @@ void swift::__swift_stdlib_ubrk_setText(
|
||||
textLength, ptr_cast<UErrorCode>(status));
|
||||
}
|
||||
|
||||
void swift::__swift_stdlib_ubrk_setUText(
|
||||
swift::__swift_stdlib_UBreakIterator *bi, __swift_stdlib_UText *text,
|
||||
__swift_stdlib_UErrorCode *status) {
|
||||
return ubrk_setUText(ptr_cast<UBreakIterator>(bi), ptr_cast<UText>(text),
|
||||
ptr_cast<UErrorCode>(status));
|
||||
}
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERFACE swift::__swift_stdlib_UText *
|
||||
swift::__swift_stdlib_utext_openUTF8(__swift_stdlib_UText *ut,
|
||||
const char *s, int64_t len,
|
||||
__swift_stdlib_UErrorCode *status) {
|
||||
return ptr_cast<__swift_stdlib_UText>(
|
||||
utext_openUTF8(ptr_cast<UText>(ut), s, len,
|
||||
ptr_cast<UErrorCode>(status)));
|
||||
}
|
||||
|
||||
SWIFT_RUNTIME_STDLIB_INTERFACE swift::__swift_stdlib_UText *
|
||||
swift::__swift_stdlib_utext_openUChars(__swift_stdlib_UText *ut,
|
||||
const __swift_stdlib_UChar *s,
|
||||
int64_t len,
|
||||
__swift_stdlib_UErrorCode *status) {
|
||||
return ptr_cast<__swift_stdlib_UText>(
|
||||
utext_openUChars(ptr_cast<UText>(ut), ptr_cast<UChar>(s), len,
|
||||
ptr_cast<UErrorCode>(status)));
|
||||
}
|
||||
|
||||
swift::__swift_stdlib_UBool swift::__swift_stdlib_unorm2_hasBoundaryBefore(
|
||||
const __swift_stdlib_UNormalizer2 *ptr, __swift_stdlib_UChar32 char32) {
|
||||
return unorm2_hasBoundaryBefore(ptr_cast<UNormalizer2>(ptr), char32);
|
||||
|
||||
Reference in New Issue
Block a user