char16_t *dest, int32_t destCapacity,
76 constchar16_t *src, int32_t srcLength,
83 classStringCharacterIterator;
84 classUnicodeStringAppendable;
98 #define US_INV icu::UnicodeString::kInvariant 120 #if !U_CHAR16_IS_TYPEDEF 121 # define UNICODE_STRING(cs, _length) icu::UnicodeString(true, u ## cs, _length) 123 # define UNICODE_STRING(cs, _length) icu::UnicodeString(true, (const char16_t*)u ## cs, _length) 135 #define UNICODE_STRING_SIMPLE(cs) UNICODE_STRING(cs, -1) 144 #ifndef UNISTR_FROM_CHAR_EXPLICIT 145 # if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) 147 # define UNISTR_FROM_CHAR_EXPLICIT explicit 150 # define UNISTR_FROM_CHAR_EXPLICIT 164 #ifndef UNISTR_FROM_STRING_EXPLICIT 165 # if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) 167 # define UNISTR_FROM_STRING_EXPLICIT explicit 170 # define UNISTR_FROM_STRING_EXPLICIT 207 #ifndef UNISTR_OBJECT_SIZE 208 # define UNISTR_OBJECT_SIZE 64 330 #ifndef U_HIDE_DRAFT_API 346 template<
typenameS,
typename= std::enable_if_t<ConvertibleToU16StringView<S>>>
348std::u16string_view sv(internal::toU16StringView(text));
350 return!isBogus() && (len =
length()) == sv.length() && doEquals(sv.data(), len);
363 #ifndef U_HIDE_DRAFT_API 381 template<
typenameS,
typename= std::enable_if_t<ConvertibleToU16StringView<S>>>
451 inlineint8_t compare(int32_t start,
472 inlineint8_t compare(int32_t start,
476int32_t srcLength)
const;
491int32_t srcLength)
const;
507 inlineint8_t compare(int32_t start,
509 constchar16_t *srcChars)
const;
528 inlineint8_t compare(int32_t start,
530 constchar16_t *srcChars,
532int32_t srcLength)
const;
551 inlineint8_t compareBetween(int32_t start,
555int32_t srcLimit)
const;
574 inlineint8_t compareCodePointOrder(
const UnicodeString& text)
const;
595 inlineint8_t compareCodePointOrder(int32_t start,
620 inlineint8_t compareCodePointOrder(int32_t start,
624int32_t srcLength)
const;
645int32_t srcLength)
const;
666 inlineint8_t compareCodePointOrder(int32_t start,
668 constchar16_t *srcChars)
const;
691 inlineint8_t compareCodePointOrder(int32_t start,
693 constchar16_t *srcChars,
695int32_t srcLength)
const;
718 inlineint8_t compareCodePointOrderBetween(int32_t start,
722int32_t srcLimit)
const;
742 inlineint8_t caseCompare(
const UnicodeString& text, uint32_t options)
const;
764 inlineint8_t caseCompare(int32_t start,
767uint32_t options)
const;
791 inlineint8_t caseCompare(int32_t start,
796uint32_t options)
const;
819uint32_t options)
const;
841 inlineint8_t caseCompare(int32_t start,
843 constchar16_t *srcChars,
844uint32_t options)
const;
868 inlineint8_t caseCompare(int32_t start,
870 constchar16_t *srcChars,
873uint32_t options)
const;
897 inlineint8_t caseCompareBetween(int32_t start,
902uint32_t options)
const;
925int32_t srcLength)
const;
936int32_t srcLength)
const;
947 inline UBoolstartsWith(
constchar16_t *srcChars,
949int32_t srcLength)
const;
972int32_t srcLength)
const;
983int32_t srcLength)
const;
995 inline UBoolendsWith(
constchar16_t *srcChars,
997int32_t srcLength)
const;
1022int32_t start)
const;
1037int32_t length)
const;
1059int32_t length)
const;
1072 inlineint32_t indexOf(
constchar16_t *srcChars,
1074int32_t start)
const;
1091int32_t length)
const;
1113int32_t length)
const;
1122 inlineint32_t indexOf(char16_t c)
const;
1132 inlineint32_t indexOf(
UChar32c)
const;
1142 inlineint32_t indexOf(char16_t c,
1143int32_t start)
const;
1154 inlineint32_t indexOf(
UChar32c,
1155int32_t start)
const;
1167 inlineint32_t indexOf(char16_t c,
1169int32_t length)
const;
1182 inlineint32_t indexOf(
UChar32c,
1184int32_t length)
const;
1194 inlineint32_t lastIndexOf(
const UnicodeString& text)
const;
1206int32_t start)
const;
1221int32_t length)
const;
1243int32_t length)
const;
1255 inlineint32_t lastIndexOf(
constchar16_t *srcChars,
1257int32_t start)
const;
1274int32_t length)
const;
1296int32_t length)
const;
1305 inlineint32_t lastIndexOf(char16_t c)
const;
1315 inlineint32_t lastIndexOf(
UChar32c)
const;
1325 inlineint32_t lastIndexOf(char16_t c,
1326int32_t start)
const;
1337 inlineint32_t lastIndexOf(
UChar32c,
1338int32_t start)
const;
1350 inlineint32_t lastIndexOf(char16_t c,
1352int32_t length)
const;
1365 inlineint32_t lastIndexOf(
UChar32c,
1367int32_t length)
const;
1380 inlinechar16_t
charAt(int32_t offset)
const;
1389 inlinechar16_t operator[] (int32_t offset)
const;
1508 inline voidextract(int32_t start,
1511int32_t dstStart = 0)
const;
1547 inline voidextract(int32_t start,
1565int32_t dstStart = 0)
const;
1601int32_t startLength,
1603int32_t targetCapacity,
1606 #if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION 1628int32_t startLength,
1630uint32_t targetLength)
const;
1634 #if !UCONFIG_NO_CONVERSION 1661 inlineint32_t extract(int32_t start,
1662int32_t startLength,
1664 const char* codepage =
nullptr)
const;
1696int32_t startLength,
1698uint32_t targetLength,
1699 const char*codepage)
const;
1718int32_t
extract(
char*dest, int32_t destCapacity,
1776 template<
typenameStringClass>
1810 inlineint32_t
length()
const;
1859 inline UBoolisEmpty()
const;
1870 inlineint32_t getCapacity()
const;
1879 inlineint32_t hashCode()
const;
1893 inline UBoolisBogus()
const;
1948 #ifndef U_HIDE_DRAFT_API 1959 template<
typenameS,
typename= std::enable_if_t<ConvertibleToU16StringView<S>>>
1962 returndoReplace(0,
length(), internal::toU16StringView(src));
1989 friend inline voidU_EXPORT2
2109int32_t textLength);
2132int32_t buffCapacity);
2215 #ifndef U_HIDE_DRAFT_API 2226 template<
typenameS,
typename= std::enable_if_t<ConvertibleToU16StringView<S>>>
2228 returndoAppend(internal::toU16StringView(src));
2288 #ifndef U_HIDE_DRAFT_API 2299 template<
typenameS,
typename= std::enable_if_t<ConvertibleToU16StringView<S>>>
2301 returndoAppend(internal::toU16StringView(src));
2367 constchar16_t *srcChars,
2467 constchar16_t *srcChars,
2580 virtual void copy(int32_t start, int32_t limit, int32_t dest)
override;
2659int32_t length =
static_cast<int32_t
>(
INT32_MAX));
2670int32_t limit =
static_cast<int32_t
>(
INT32_MAX));
2697char16_t padChar = 0x0020);
2711char16_t padChar = 0x0020);
2719 inline UBooltruncate(int32_t targetLength);
2782 #if !UCONFIG_NO_BREAK_ITERATION 2991 inline constchar16_t *getBuffer()
const;
3028 #ifndef U_HIDE_DRAFT_API 3035 inline operatorstd::u16string_view()
const{
3036 return{getBuffer(),
static_cast<std::u16string_view::size_type
>(
length())};
3039 #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN) 3049 inline operatorstd::wstring_view()
const{
3050 constchar16_t *p = getBuffer();
3051 #ifdef U_ALIASING_BARRIER 3054 return{
reinterpret_cast<const wchar_t*
>(p), (std::wstring_view::size_type)
length() };
3103 #ifdef U_HIDE_DRAFT_API 3127 #if !U_CHAR16_IS_TYPEDEF && \ 3128 (defined(U_HIDE_DRAFT_API) || (defined(_LIBCPP_VERSION) && _LIBCPP_VERSION >= 180000)) 3152 #if defined(U_HIDE_DRAFT_API) && (U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)) 3174UnicodeString(ConstChar16Ptr(text), -1) {}
3206int32_t textLength);
3208 #if !U_CHAR16_IS_TYPEDEF 3229 #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN) 3258 inline UnicodeString(
conststd::nullptr_t text, int32_t textLength);
3260 #ifndef U_HIDE_DRAFT_API 3273 template<
typenameS,
typename= std::enable_if_t<ConvertibleToU16StringView<S>>>
3275fUnion.fFields.fLengthAndFlags = kShortString;
3276doAppend(internal::toU16StringViewNullable(text));
3312int32_t textLength);
3334 #if !U_CHAR16_IS_TYPEDEF 3347 #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN) 3369 inline UnicodeString(std::nullptr_t buffer, int32_t buffLength, int32_t buffCapacity);
3371 #if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION 3410 #if !UCONFIG_NO_CONVERSION 3448 UnicodeString(
const char*codepageData, int32_t dataLength,
const char*codepage);
3472 const char*src, int32_t srcLength,
3576 #ifndef U_HIDE_DRAFT_API 3599 template<
typenameS,
typename= std::enable_if_t<ConvertibleToU16StringView<S>>>
3601 returnreadOnlyAliasFromU16StringView(internal::toU16StringView(text));
3624 returnreadOnlyAliasFromUnicodeString(text);
3745 virtualchar16_t
getCharAt(int32_t offset)
const override;
3755 static UnicodeStringreadOnlyAliasFromU16StringView(std::u16string_view text);
3766toUTF8(int32_t start, int32_t len,
3767 char*target, int32_t capacity)
const;
3774 returndoEquals(text.getArrayStart(), len);
3776 UBooldoEquals(
constchar16_t *text, int32_t len)
const;
3779doEqualsSubstring(int32_t start,
3783int32_t srcLength)
const;
3785 UBooldoEqualsSubstring(int32_t start,
3787 constchar16_t *srcChars,
3789int32_t srcLength)
const;
3792doCompare(int32_t start,
3796int32_t srcLength)
const;
3798int8_t doCompare(int32_t start,
3800 constchar16_t *srcChars,
3802int32_t srcLength)
const;
3805doCompareCodePointOrder(int32_t start,
3809int32_t srcLength)
const;
3811int8_t doCompareCodePointOrder(int32_t start,
3813 constchar16_t *srcChars,
3815int32_t srcLength)
const;
3818doCaseCompare(int32_t start,
3823uint32_t options)
const;
3826doCaseCompare(int32_t start,
3828 constchar16_t *srcChars,
3831uint32_t options)
const;
3833int32_t doIndexOf(char16_t c,
3835int32_t length)
const;
3839int32_t length)
const;
3841int32_t doLastIndexOf(char16_t c,
3843int32_t length)
const;
3845int32_t doLastIndexOf(
UChar32c,
3847int32_t length)
const;
3849 voiddoExtract(int32_t start,
3852int32_t dstStart)
const;
3854 inline voiddoExtract(int32_t start,
3858 inlinechar16_t doCharAt(int32_t offset)
const;
3868 constchar16_t *srcChars,
3871 UnicodeString& doReplace(int32_t start, int32_t length, std::u16string_view src);
3874 UnicodeString& doAppend(
constchar16_t *srcChars, int32_t srcStart, int32_t srcLength);
3881int32_t doHashCode()
const;
3885 inlinechar16_t* getArrayStart();
3886 inline constchar16_t* getArrayStart()
const;
3888 inline UBoolhasShortLength()
const;
3889 inlineint32_t getShortLength()
const;
3893 inline UBoolisWritable()
const;
3896 inline UBoolisBufferWritable()
const;
3899 inline voidsetZeroLength();
3900 inline voidsetShortLength(int32_t len);
3901 inline voidsetLength(int32_t len);
3902 inline voidsetToEmpty();
3903 inline voidsetArray(char16_t *array, int32_t len, int32_t capacity);
3910 UBoolallocate(int32_t capacity);
3913 voidreleaseArray();
3925 inline voidpinIndex(int32_t& start)
const;
3926 inline voidpinIndices(int32_t& start,
3927int32_t& length)
const;
3929 #if !UCONFIG_NO_CONVERSION 3932int32_t doExtract(int32_t start, int32_t length,
3933 char*dest, int32_t destCapacity,
3947 voiddoCodepageCreate(
const char*codepageData,
3949 const char*codepage);
3956doCodepageCreate(
const char*codepageData,
3974 UBoolcloneArrayIfNeeded(int32_t newCapacity = -1,
3975int32_t growCapacity = -1,
3976 UBooldoCopyArray =
true,
3977int32_t** pBufferToDelete =
nullptr,
3978 UBoolforceClone =
false);
3986caseMap(int32_t caseLocale, uint32_t options,
3994int32_t removeRef();
3995int32_t refCount()
const;
4005kInvalidUChar=0xffff,
4011kUsingStackBuffer=2,
4013kBufferIsReadonly=8,
4016kAllStorageFlags=0x1f,
4019kLength1=1<<kLengthShift,
4020kMaxShortLength=0x3ff,
4021kLengthIsLarge=0xffe0,
4024kShortString=kUsingStackBuffer,
4025kLongString=kRefCounted,
4026kReadonlyAlias=kBufferIsReadonly,
4030 friend classUnicodeStringAppendable;
4032 unionStackBufferOrFields;
4033 friend unionStackBufferOrFields;
4076 unionStackBufferOrFields {
4080int16_t fLengthAndFlags;
4081char16_t fBuffer[US_STACKBUF_SIZE];
4084int16_t fLengthAndFlags;
4105 #ifndef U_HIDE_DRAFT_API 4116 template<
typenameS,
typename= std::enable_if_t<ConvertibleToU16StringView<S>>>
4122 #ifndef U_FORCE_HIDE_INTERNAL_API 4137UnicodeString::pinIndex(int32_t& start)
const 4142}
else if(start > length()) {
4148UnicodeString::pinIndices(int32_t& start,
4149int32_t& _length)
const 4152int32_t len = length();
4155}
else if(start > len) {
4160}
else if(_length > (len - start)) {
4161_length = (len - start);
4166UnicodeString::getArrayStart() {
4167 return(fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
4168fUnion.fStackFields.fBuffer : fUnion.fFields.fArray;
4171 inline constchar16_t*
4172UnicodeString::getArrayStart()
const{
4173 return(fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
4174fUnion.fStackFields.fBuffer : fUnion.fFields.fArray;
4182UnicodeString::UnicodeString() {
4183fUnion.fStackFields.fLengthAndFlags=kShortString;
4186 inlineUnicodeString::UnicodeString(
conststd::nullptr_t
) {
4187fUnion.fStackFields.fLengthAndFlags=kShortString;
4190 inlineUnicodeString::UnicodeString(
conststd::nullptr_t
, int32_t
) {
4191fUnion.fStackFields.fLengthAndFlags=kShortString;
4194 inlineUnicodeString::UnicodeString(std::nullptr_t
, int32_t
, int32_t
) {
4195fUnion.fStackFields.fLengthAndFlags=kShortString;
4202UnicodeString::hasShortLength()
const{
4203 returnfUnion.fFields.fLengthAndFlags>=0;
4207UnicodeString::getShortLength()
const{
4210 returnfUnion.fFields.fLengthAndFlags>>kLengthShift;
4214UnicodeString::length()
const{
4215 returnhasShortLength() ? getShortLength() : fUnion.fFields.fLength;
4219UnicodeString::getCapacity()
const{
4220 return(fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
4221US_STACKBUF_SIZE : fUnion.fFields.fCapacity;
4225UnicodeString::hashCode()
const 4226{
returndoHashCode(); }
4229UnicodeString::isBogus()
const 4230{
returnfUnion.fFields.fLengthAndFlags & kIsBogus; }
4233UnicodeString::isWritable()
const 4234{
return!(fUnion.fFields.fLengthAndFlags & (kOpenGetBuffer | kIsBogus)); }
4237UnicodeString::isBufferWritable()
const 4240!(fUnion.fFields.fLengthAndFlags&(kOpenGetBuffer|kIsBogus|kBufferIsReadonly)) &&
4241(!(fUnion.fFields.fLengthAndFlags&kRefCounted) || refCount()==1);
4244 inline constchar16_t *
4245UnicodeString::getBuffer()
const{
4246 if(fUnion.fFields.fLengthAndFlags&(kIsBogus|kOpenGetBuffer)) {
4248}
else if(fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) {
4249 returnfUnion.fStackFields.fBuffer;
4251 returnfUnion.fFields.fArray;
4259UnicodeString::doCompare(int32_t start,
4263int32_t srcLength)
const 4266 return static_cast<int8_t
>(!isBogus());
4268srcText.pinIndices(srcStart, srcLength);
4269 returndoCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
4274UnicodeString::doEqualsSubstring(int32_t start,
4276 constUnicodeString& srcText,
4278int32_t srcLength)
const 4280 if(srcText.isBogus()) {
4283srcText.pinIndices(srcStart, srcLength);
4284 return!isBogus() && doEqualsSubstring(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
4294int32_t len = length(), textLength = text.
length();
4295 return!text.
isBogus() && len == textLength && doEquals(text, len);
4301{
return(!
operator==(text)); }
4305{
returndoCompare(0, length(), text, 0, text.
length()) == 1; }
4308UnicodeString::operator< (
const UnicodeString& text)
const 4309{
returndoCompare(0, length(), text, 0, text.
length()) == -1; }
4313{
returndoCompare(0, length(), text, 0, text.
length()) != -1; }
4316UnicodeString::operator<= (
const UnicodeString& text)
const 4317{
returndoCompare(0, length(), text, 0, text.
length()) != 1; }
4321{
returndoCompare(0, length(), text, 0, text.
length()); }
4324UnicodeString::compare(int32_t start,
4327{
returndoCompare(start, _length, srcText, 0, srcText.
length()); }
4331int32_t srcLength)
const 4332{
returndoCompare(0, length(), srcChars, 0, srcLength); }
4335UnicodeString::compare(int32_t start,
4339int32_t srcLength)
const 4340{
returndoCompare(start, _length, srcText, srcStart, srcLength); }
4343UnicodeString::compare(int32_t start,
4345 constchar16_t *srcChars)
const 4346{
returndoCompare(start, _length, srcChars, 0, _length); }
4349UnicodeString::compare(int32_t start,
4351 constchar16_t *srcChars,
4353int32_t srcLength)
const 4354{
returndoCompare(start, _length, srcChars, srcStart, srcLength); }
4357UnicodeString::compareBetween(int32_t start,
4361int32_t srcLimit)
const 4362{
returndoCompare(start, limit - start,
4363srcText, srcStart, srcLimit - srcStart); }
4366UnicodeString::doCompareCodePointOrder(int32_t start,
4370int32_t srcLength)
const 4373 return static_cast<int8_t
>(!isBogus());
4375srcText.pinIndices(srcStart, srcLength);
4376 returndoCompareCodePointOrder(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
4382{
returndoCompareCodePointOrder(0, length(), text, 0, text.
length()); }
4385UnicodeString::compareCodePointOrder(int32_t start,
4388{
returndoCompareCodePointOrder(start, _length, srcText, 0, srcText.
length()); }
4392int32_t srcLength)
const 4393{
returndoCompareCodePointOrder(0, length(), srcChars, 0, srcLength); }
4396UnicodeString::compareCodePointOrder(int32_t start,
4400int32_t srcLength)
const 4401{
returndoCompareCodePointOrder(start, _length, srcText, srcStart, srcLength); }
4404UnicodeString::compareCodePointOrder(int32_t start,
4406 constchar16_t *srcChars)
const 4407{
returndoCompareCodePointOrder(start, _length, srcChars, 0, _length); }
4410UnicodeString::compareCodePointOrder(int32_t start,
4412 constchar16_t *srcChars,
4414int32_t srcLength)
const 4415{
returndoCompareCodePointOrder(start, _length, srcChars, srcStart, srcLength); }
4418UnicodeString::compareCodePointOrderBetween(int32_t start,
4422int32_t srcLimit)
const 4423{
returndoCompareCodePointOrder(start, limit - start,
4424srcText, srcStart, srcLimit - srcStart); }
4427UnicodeString::doCaseCompare(int32_t start,
4432uint32_t options)
const 4435 return static_cast<int8_t
>(!isBogus());
4437srcText.pinIndices(srcStart, srcLength);
4438 returndoCaseCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength, options);
4443UnicodeString::caseCompare(
const UnicodeString&text, uint32_t options)
const{
4444 returndoCaseCompare(0, length(), text, 0, text.
length(), options);
4448UnicodeString::caseCompare(int32_t start,
4451uint32_t options)
const{
4452 returndoCaseCompare(start, _length, srcText, 0, srcText.
length(), options);
4458uint32_t options)
const{
4459 returndoCaseCompare(0, length(), srcChars, 0, srcLength, options);
4463UnicodeString::caseCompare(int32_t start,
4468uint32_t options)
const{
4469 returndoCaseCompare(start, _length, srcText, srcStart, srcLength, options);
4473UnicodeString::caseCompare(int32_t start,
4475 constchar16_t *srcChars,
4476uint32_t options)
const{
4477 returndoCaseCompare(start, _length, srcChars, 0, _length, options);
4481UnicodeString::caseCompare(int32_t start,
4483 constchar16_t *srcChars,
4486uint32_t options)
const{
4487 returndoCaseCompare(start, _length, srcChars, srcStart, srcLength, options);
4491UnicodeString::caseCompareBetween(int32_t start,
4496uint32_t options)
const{
4497 returndoCaseCompare(start, limit - start, srcText, srcStart, srcLimit - srcStart, options);
4505int32_t _length)
const 4508srcText.pinIndices(srcStart, srcLength);
4509 if(srcLength > 0) {
4510 returnindexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
4518{
returnindexOf(text, 0, text.
length(), 0, length()); }
4522int32_t start)
const{
4524 returnindexOf(text, 0, text.
length(), start, length() - start);
4530int32_t _length)
const 4531{
returnindexOf(text, 0, text.
length(), start, _length); }
4534UnicodeString::indexOf(
constchar16_t *srcChars,
4536int32_t start)
const{
4538 returnindexOf(srcChars, 0, srcLength, start, length() - start);
4545int32_t _length)
const 4546{
returnindexOf(srcChars, 0, srcLength, start, _length); }
4549UnicodeString::indexOf(char16_t c,
4551int32_t _length)
const 4552{
returndoIndexOf(c, start, _length); }
4557int32_t _length)
const 4558{
returndoIndexOf(c, start, _length); }
4561UnicodeString::indexOf(char16_t c)
const 4562{
returndoIndexOf(c, 0, length()); }
4566{
returnindexOf(c, 0, length()); }
4569UnicodeString::indexOf(char16_t c,
4570int32_t start)
const{
4572 returndoIndexOf(c, start, length() - start);
4577int32_t start)
const{
4579 returnindexOf(c, start, length() - start);
4586int32_t _length)
const 4587{
returnlastIndexOf(srcChars, 0, srcLength, start, _length); }
4590UnicodeString::lastIndexOf(
constchar16_t *srcChars,
4592int32_t start)
const{
4594 returnlastIndexOf(srcChars, 0, srcLength, start, length() - start);
4602int32_t _length)
const 4605srcText.pinIndices(srcStart, srcLength);
4606 if(srcLength > 0) {
4607 returnlastIndexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
4616int32_t _length)
const 4617{
returnlastIndexOf(text, 0, text.
length(), start, _length); }
4621int32_t start)
const{
4623 returnlastIndexOf(text, 0, text.
length(), start, length() - start);
4628{
returnlastIndexOf(text, 0, text.
length(), 0, length()); }
4631UnicodeString::lastIndexOf(char16_t c,
4633int32_t _length)
const 4634{
returndoLastIndexOf(c, start, _length); }
4639int32_t _length)
const{
4640 returndoLastIndexOf(c, start, _length);
4644UnicodeString::lastIndexOf(char16_t c)
const 4645{
returndoLastIndexOf(c, 0, length()); }
4649 returnlastIndexOf(c, 0, length());
4653UnicodeString::lastIndexOf(char16_t c,
4654int32_t start)
const{
4656 returndoLastIndexOf(c, start, length() - start);
4661int32_t start)
const{
4663 returnlastIndexOf(c, start, length() - start);
4668{
returndoEqualsSubstring(0, text.
length(), text, 0, text.
length()); }
4673int32_t srcLength)
const 4674{
returndoEqualsSubstring(0, srcLength, srcText, srcStart, srcLength); }
4678 if(srcLength < 0) {
4679srcLength =
u_strlen(toUCharPtr(srcChars));
4681 returndoEqualsSubstring(0, srcLength, srcChars, 0, srcLength);
4685UnicodeString::startsWith(
constchar16_t *srcChars, int32_t srcStart, int32_t srcLength)
const{
4686 if(srcLength < 0) {
4687srcLength =
u_strlen(toUCharPtr(srcChars));
4689 returndoEqualsSubstring(0, srcLength, srcChars, srcStart, srcLength);
4694{
returndoEqualsSubstring(length() - text.
length(), text.
length(),
4695text, 0, text.
length()); }
4700int32_t srcLength)
const{
4701srcText.pinIndices(srcStart, srcLength);
4702 returndoEqualsSubstring(length() - srcLength, srcLength,
4703srcText, srcStart, srcLength);
4708int32_t srcLength)
const{
4709 if(srcLength < 0) {
4710srcLength =
u_strlen(toUCharPtr(srcChars));
4712 returndoEqualsSubstring(length() - srcLength, srcLength, srcChars, 0, srcLength);
4716UnicodeString::endsWith(
constchar16_t *srcChars,
4718int32_t srcLength)
const{
4719 if(srcLength < 0) {
4720srcLength =
u_strlen(toUCharPtr(srcChars + srcStart));
4722 returndoEqualsSubstring(length() - srcLength, srcLength,
4723srcChars, srcStart, srcLength);
4730UnicodeString::replace(int32_t start,
4733{
returndoReplace(start, _length, srcText, 0, srcText.
length()); }
4736UnicodeString::replace(int32_t start,
4741{
returndoReplace(start, _length, srcText, srcStart, srcLength); }
4744UnicodeString::replace(int32_t start,
4748{
returndoReplace(start, _length, srcChars, 0, srcLength); }
4751UnicodeString::replace(int32_t start,
4753 constchar16_t *srcChars,
4756{
returndoReplace(start, _length, srcChars, srcStart, srcLength); }
4759UnicodeString::replace(int32_t start,
4762{
returndoReplace(start, _length, &srcChar, 0, 1); }
4765UnicodeString::replaceBetween(int32_t start,
4768{
returndoReplace(start, limit - start, srcText, 0, srcText.
length()); }
4771UnicodeString::replaceBetween(int32_t start,
4776{
returndoReplace(start, limit - start, srcText, srcStart, srcLimit - srcStart); }
4781{
returnfindAndReplace(0, length(), oldText, 0, oldText.
length(),
4782newText, 0, newText.
length()); }
4785UnicodeString::findAndReplace(int32_t start,
4789{
returnfindAndReplace(start, _length, oldText, 0, oldText.
length(),
4790newText, 0, newText.
length()); }
4796UnicodeString::doExtract(int32_t start,
4799{ target.
replace(0, target.
length(), *
this, start, _length); }
4802UnicodeString::extract(int32_t start,
4805int32_t targetStart)
const 4806{ doExtract(start, _length, target, targetStart); }
4809UnicodeString::extract(int32_t start,
4812{ doExtract(start, _length, target); }
4814 #if !UCONFIG_NO_CONVERSION 4817UnicodeString::extract(int32_t start,
4820 const char*codepage)
const 4824 returnextract(start, _length, dst, dst !=
nullptr? 0xffffffff : 0, codepage);
4830UnicodeString::extractBetween(int32_t start,
4833int32_t dstStart)
const{
4836doExtract(start, limit - start, dst, dstStart);
4840UnicodeString::tempSubStringBetween(int32_t start, int32_t limit)
const{
4841 returntempSubString(start, limit - start);
4845UnicodeString::doCharAt(int32_t offset)
const 4847 if(
static_cast<uint32_t
>(offset) <
static_cast<uint32_t
>(length())) {
4848 returngetArrayStart()[offset];
4850 returnkInvalidUChar;
4855UnicodeString::charAt(int32_t offset)
const 4856{
returndoCharAt(offset); }
4859UnicodeString::operator[] (int32_t offset)
const 4860{
returndoCharAt(offset); }
4863UnicodeString::isEmpty()
const{
4865 return(fUnion.fFields.fLengthAndFlags>>kLengthShift) == 0;
4872UnicodeString::setZeroLength() {
4873fUnion.fFields.fLengthAndFlags &= kAllStorageFlags;
4877UnicodeString::setShortLength(int32_t len) {
4879fUnion.fFields.fLengthAndFlags =
4880 static_cast<int16_t
>((fUnion.fFields.fLengthAndFlags & kAllStorageFlags) | (len << kLengthShift));
4884UnicodeString::setLength(int32_t len) {
4885 if(len <= kMaxShortLength) {
4886setShortLength(len);
4888fUnion.fFields.fLengthAndFlags |= kLengthIsLarge;
4889fUnion.fFields.fLength = len;
4894UnicodeString::setToEmpty() {
4895fUnion.fFields.fLengthAndFlags = kShortString;
4899UnicodeString::setArray(char16_t *array, int32_t len, int32_t capacity) {
4901fUnion.fFields.fArray = array;
4902fUnion.fFields.fCapacity = capacity;
4905 inlineUnicodeString&
4906UnicodeString::operator= (char16_t ch)
4907{
returndoReplace(0, length(), &ch, 0, 1); }
4911{
returnreplace(0, length(), ch); }
4919 returndoReplace(0, length(), srcText, srcStart, srcLength);
4927srcText.pinIndex(srcStart);
4928 returndoReplace(0, length(), srcText, srcStart, srcText.
length() - srcStart);
4934 returncopyFrom(srcText);
4938UnicodeString::setTo(
constchar16_t *srcChars,
4942 returndoReplace(0, length(), srcChars, 0, srcLength);
4946UnicodeString::setTo(char16_t srcChar)
4949 returndoReplace(0, length(), &srcChar, 0, 1);
4956 returnreplace(0, length(), srcChar);
4963{
returndoAppend(srcText, srcStart, srcLength); }
4967{
returndoAppend(srcText, 0, srcText.
length()); }
4970UnicodeString::append(
constchar16_t *srcChars,
4973{
returndoAppend(srcChars, srcStart, srcLength); }
4978{
returndoAppend(srcChars, 0, srcLength); }
4981UnicodeString::append(char16_t srcChar)
4982{
returndoAppend(&srcChar, 0, 1); }
4985UnicodeString::operator+= (char16_t ch)
4986{
returndoAppend(&ch, 0, 1); }
4995{
returndoAppend(srcText, 0, srcText.
length()); }
4998UnicodeString::insert(int32_t start,
5002{
returndoReplace(start, 0, srcText, srcStart, srcLength); }
5005UnicodeString::insert(int32_t start,
5007{
returndoReplace(start, 0, srcText, 0, srcText.
length()); }
5010UnicodeString::insert(int32_t start,
5011 constchar16_t *srcChars,
5014{
returndoReplace(start, 0, srcChars, srcStart, srcLength); }
5017UnicodeString::insert(int32_t start,
5020{
returndoReplace(start, 0, srcChars, 0, srcLength); }
5023UnicodeString::insert(int32_t start,
5025{
returndoReplace(start, 0, &srcChar, 0, 1); }
5028UnicodeString::insert(int32_t start,
5030{
returnreplace(start, 0, srcChar); }
5034UnicodeString::remove()
5046UnicodeString::remove(int32_t start,
5049 if(start <= 0 && _length ==
INT32_MAX) {
5053 returndoReplace(start, _length,
nullptr, 0, 0);
5057UnicodeString::removeBetween(int32_t start,
5059{
returndoReplace(start, limit - start,
nullptr, 0, 0); }
5062UnicodeString::retainBetween(int32_t start, int32_t limit) {
5064 returndoReplace(0, start,
nullptr, 0, 0);
5068UnicodeString::truncate(int32_t targetLength)
5070 if(isBogus() && targetLength == 0) {
5074}
else if(
static_cast<uint32_t
>(targetLength) <
static_cast<uint32_t
>(length())) {
5075setLength(targetLength);
5083UnicodeString::reverse()
5084{
returndoReverse(0, length()); }
5087UnicodeString::reverse(int32_t start,
5089{
returndoReverse(start, _length); }
C++ API: Interface for writing bytes, and implementation classes.
C++ API: char16_t pointer wrappers with implicit conversion from bit-compatible raw pointer types.
#define U_ALIASING_BARRIER(ptr)
Barrier for pointer anti-aliasing optimizations even across function boundaries.
The BreakIterator class implements methods for finding the location of boundaries in text.
A ByteSink can be filled with bytes.
char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types.
const char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types.
Records lengths of string edits but not replacement text.
A Locale object represents a specific geographical, political, or cultural region.
Replaceable is an abstract base class representing a string of characters that supports the replaceme...
virtual void extractBetween(int32_t start, int32_t limit, UnicodeString &target) const =0
Copies characters in the range [start, limit) into the UnicodeString target.
char16_t charAt(int32_t offset) const
Returns the 16-bit code unit at the given offset into the text.
int32_t length() const
Returns the number of 16-bit code units in the text.
Implementation of ByteSink that writes to a "string".
A string-like object that points to a sized piece of memory.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
int32_t indexOf(const char16_t *srcChars, int32_t srcStart, int32_t srcLength, int32_t start, int32_t length) const
Locate in this the first occurrence in the range [start, start + length) of the characters in srcChar...
UnicodeString(const UnicodeString &that)
Copy constructor.
void swap(UnicodeString &other) noexcept
Swap strings.
virtual char16_t getCharAt(int32_t offset) const override
The change in Replaceable to use virtual getCharAt() allows UnicodeString::charAt() to be inline agai...
bool operator==(const S &text) const
Equality operator.
virtual int32_t getLength() const override
Implement Replaceable::getLength() (see jitterbug 1027).
UnicodeString & foldCase(uint32_t options=0)
Case-folds the characters in this string.
UChar32 unescapeAt(int32_t &offset) const
Unescape a single escape sequence and return the represented character.
UnicodeString(const wchar_t *text, int32_t textLength)
wchar_t * constructor.
virtual void handleReplaceBetween(int32_t start, int32_t limit, const UnicodeString &text) override
Replace a substring of this object with the given text.
UBool hasMoreChar32Than(int32_t start, int32_t length, int32_t number) const
Check if the length char16_t code units of the string contain more Unicode code points than a certain...
UnicodeString(const UnicodeString &src, int32_t srcStart, int32_t srcLength)
'Substring' constructor from subrange of source string.
UnicodeString & operator=(const S &src)
Assignment operator.
UnicodeString & append(const S &src)
Appends the characters in src which is, or which is implicitly convertible to, a std::u16string_view ...
UnicodeString & operator=(UnicodeString &&src) noexcept
Move assignment operator; might leave src in bogus state.
virtual ~UnicodeString()
Destructor.
UnicodeString(const char *codepageData, int32_t dataLength, const char *codepage)
char* constructor.
UnicodeString & toLower()
Convert the characters in this to lower case following the conventions of the default locale.
UnicodeString(const char *codepageData, const char *codepage)
char* constructor.
UnicodeString(UBool isTerminated, ConstChar16Ptr text, int32_t textLength)
Readonly-aliasing char16_t* constructor.
static UnicodeString readOnlyAlias(const UnicodeString &text)
Readonly-aliasing factory method.
UnicodeString & fastCopyFrom(const UnicodeString &src)
Almost the same as the assignment operator.
UnicodeString & toTitle(BreakIterator *titleIter)
Titlecase this string, convenience function using the default locale.
EInvariant
Constant to be used in the UnicodeString(char *, int32_t, EInvariant) constructor which constructs a ...
bool operator!=(const S &text) const
Inequality operator.
UnicodeString unescape() const
Unescape a string of characters and return a string containing the result.
UnicodeString(const UnicodeString &src, int32_t srcStart)
'Substring' constructor from tail of source string.
int32_t getChar32Limit(int32_t offset) const
Adjust a random-access offset so that it points behind a Unicode character.
UnicodeString(char16_t *buffer, int32_t buffLength, int32_t buffCapacity)
Writable-aliasing char16_t* constructor.
UnicodeString(int32_t capacity, UChar32 c, int32_t count)
Construct a UnicodeString with capacity to hold capacity char16_ts.
int32_t extract(int32_t start, int32_t startLength, char *target, uint32_t targetLength, const char *codepage) const
Copy the characters in the range [start, start + length) into an array of characters in a specified c...
UnicodeString & findAndReplace(int32_t start, int32_t length, const UnicodeString &oldText, int32_t oldStart, int32_t oldLength, const UnicodeString &newText, int32_t newStart, int32_t newLength)
Replace all occurrences of characters in oldText in the range [oldStart, oldStart + oldLength) with t...
virtual void copy(int32_t start, int32_t limit, int32_t dest) override
Copy a substring of this object, retaining attribute (out-of-band) information.
virtual void extractBetween(int32_t start, int32_t limit, UnicodeString &target) const override
Copy the characters in the range [start, limit) into the UnicodeString target.
UnicodeString & replace(int32_t start, int32_t length, const UnicodeString &srcText, int32_t srcStart, int32_t srcLength)
Replace the characters in the range [start, start + length) with the characters in srcText in the ran...
UBool padLeading(int32_t targetLength, char16_t padChar=0x0020)
Pad the start of this UnicodeString with the character padChar.
int32_t getChar32Start(int32_t offset) const
Adjust a random-access offset so that it points to the beginning of a Unicode character.
UChar32 char32At(int32_t offset) const
Return the code point that contains the code unit at offset offset.
UnicodeString(const char *src, int32_t textLength, enum EInvariant inv)
Constructs a Unicode string from an invariant-character char * string.
UnicodeString & operator=(const UnicodeString &srcText)
Assignment operator.
UnicodeString & append(UChar32 srcChar)
Append the code point srcChar to the UnicodeString object.
StringClass & toUTF8String(StringClass &result) const
Convert the UnicodeString to UTF-8 and append the result to a standard string.
UnicodeString & toLower(const Locale &locale)
Convert the characters in this to lower case following the conventions of a specific locale.
UnicodeString & toTitle(BreakIterator *titleIter, const Locale &locale)
Titlecase this string.
UnicodeString tempSubString(int32_t start=0, int32_t length=INT32_MAX) const
Create a temporary substring for the specified range.
int32_t extract(Char16Ptr dest, int32_t destCapacity, UErrorCode &errorCode) const
Copy the contents of the string into dest.
int32_t length() const
Return the length of the UnicodeString object.
virtual UChar32 getChar32At(int32_t offset) const override
The change in Replaceable to use virtual getChar32At() allows UnicodeString::char32At() to be inline ...
int32_t extract(int32_t start, int32_t startLength, char *target, uint32_t targetLength) const
Copy the characters in the range [start, start + length) into an array of characters in the platform'...
static UnicodeString fromUTF8(StringPiece utf8)
Create a UnicodeString from a UTF-8 string.
UNISTR_FROM_CHAR_EXPLICIT UnicodeString(char16_t ch)
Single char16_t (code unit) constructor.
int32_t lastIndexOf(const char16_t *srcChars, int32_t srcStart, int32_t srcLength, int32_t start, int32_t length) const
Locate in this the last occurrence in the range [start, start + length) of the characters in srcChars...
UnicodeString(wchar_t *buffer, int32_t buffLength, int32_t buffCapacity)
Writable-aliasing wchar_t * constructor.
void setToBogus()
Make this UnicodeString object invalid.
friend void swap(UnicodeString &s1, UnicodeString &s2) noexcept
Non-member UnicodeString swap function.
int32_t moveIndex32(int32_t index, int32_t delta) const
Move the code unit index along the string by delta code points.
static UnicodeString fromUTF32(const UChar32 *utf32, int32_t length)
Create a UnicodeString from a UTF-32 string.
UNISTR_FROM_STRING_EXPLICIT UnicodeString(const S &text)
Constructor from text which is, or which is implicitly convertible to, a std::u16string_view or (if U...
int32_t countChar32(int32_t start=0, int32_t length=INT32_MAX) const
Count Unicode code points in the length char16_t code units of the string.
UNISTR_FROM_CHAR_EXPLICIT UnicodeString(UChar32 ch)
Single UChar32 (code point) constructor.
UnicodeString & setTo(UBool isTerminated, ConstChar16Ptr text, int32_t textLength)
Aliasing setTo() function, analogous to the readonly-aliasing char16_t* constructor.
static UnicodeString readOnlyAlias(const S &text)
Readonly-aliasing factory method.
UnicodeString & operator+=(const S &src)
Append operator.
UnicodeString & toTitle(BreakIterator *titleIter, const Locale &locale, uint32_t options)
Titlecase this string, with options.
virtual UnicodeString * clone() const override
Clone this object, an instance of a subclass of Replaceable.
int32_t extract(char *dest, int32_t destCapacity, UConverter *cnv, UErrorCode &errorCode) const
Convert the UnicodeString into a codepage string using an existing UConverter.
UnicodeString(UnicodeString &&src) noexcept
Move constructor; might leave src in bogus state.
UnicodeString(const char16_t *text, int32_t textLength)
char16_t* constructor.
UnicodeString & replace(int32_t start, int32_t length, UChar32 srcChar)
Replace the characters in the range [start, start + length) with the code point srcChar.
UnicodeString(const char *src, int32_t srcLength, UConverter *cnv, UErrorCode &errorCode)
char * / UConverter constructor.
UnicodeString(const char *codepageData, int32_t dataLength)
char* constructor.
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
UnicodeString(uint16_t *buffer, int32_t buffLength, int32_t buffCapacity)
Writable-aliasing uint16_t * constructor.
int32_t toUTF32(UChar32 *utf32, int32_t capacity, UErrorCode &errorCode) const
Convert the UnicodeString to UTF-32.
UBool isBogus() const
Determine if this object contains a valid string.
const char16_t * getTerminatedBuffer()
Get a read-only pointer to the internal buffer, making sure that it is NUL-terminated.
UnicodeString(const uint16_t *text, int32_t textLength)
uint16_t * constructor.
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
int32_t extract(int32_t start, int32_t startLength, char *target, int32_t targetCapacity, enum EInvariant inv) const
Copy the characters in the range [start, start + startLength) into an array of characters.
UnicodeString & setCharAt(int32_t offset, char16_t ch)
Set the character at the specified offset to the specified character.
UnicodeString & setTo(char16_t *buffer, int32_t buffLength, int32_t buffCapacity)
Aliasing setTo() function, analogous to the writable-aliasing char16_t* constructor.
UBool padTrailing(int32_t targetLength, char16_t padChar=0x0020)
Pad the end of this UnicodeString with the character padChar.
UNISTR_FROM_STRING_EXPLICIT UnicodeString(const char *codepageData)
char* constructor.
void releaseBuffer(int32_t newLength=-1)
Release a read/write buffer on a UnicodeString object with an "open" getBuffer(minCapacity).
char16_t * getBuffer(int32_t minCapacity)
Get a read/write pointer to the internal buffer.
void toUTF8(ByteSink &sink) const
Convert the UnicodeString to UTF-8 and write the result to a ByteSink.
virtual UBool hasMetaData() const override
Replaceable API.
UnicodeString & toUpper()
Convert the characters in this to UPPER CASE following the conventions of the default locale.
UnicodeString & toUpper(const Locale &locale)
Convert the characters in this to UPPER CASE following the conventions of a specific locale.
UnicodeString & trim()
Trims leading and trailing whitespace from this UnicodeString.
U_CAPI int32_t u_strlen(const UChar *s)
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
U_COMMON_API UnicodeString unistr_internalConcat(const UnicodeString &s1, std::u16string_view s2)
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
UnicodeString operator+(const UnicodeString &s1, const S &s2)
Creates a new UnicodeString from the concatenation of a UnicodeString and s2 which is,...
#define U_CALLCONV
Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary in callback function typedefs to ma...
C++ API: Replaceable String.
C++ API: Central ICU header for including the C++ standard <string> header and for related definition...
C++ API: StringPiece: Read-only byte string wrapper class.
struct UConverter UConverter
#define UCONFIG_NO_BREAK_ITERATION
This switch turns off break iteration.
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
#define INT32_MAX
The largest value a 32 bit signed integer can hold.
int8_t UBool
The ICU boolean type, a signed-byte integer.
#define U_CAPI
This is used to declare a function as a public ICU C API.
char16_t UChar
The base type for UTF-16 code units and pointers.
#define U_SIZEOF_UCHAR
Number of bytes in a UChar (always 2).
#define UNISTR_FROM_CHAR_EXPLICIT
This can be defined to be empty or "explicit".
int32_t UStringCaseMapper(int32_t caseLocale, uint32_t options, icu::BreakIterator *iter, char16_t *dest, int32_t destCapacity, const char16_t *src, int32_t srcLength, icu::Edits *edits, UErrorCode &errorCode)
Internal string case mapping function type.
#define UNISTR_FROM_STRING_EXPLICIT
This can be defined to be empty or "explicit".
#define UNISTR_OBJECT_SIZE
Desired sizeof(UnicodeString) in bytes.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4