38 #ifndef U_COMPARE_CODE_POINT_ORDER
45 #define U_COMPARE_CODE_POINT_ORDER 0x8000
60 #ifndef U_STRING_CASE_MAPPER_DEFINED
61 #define U_STRING_CASE_MAPPER_DEFINED
69 UChar *dest, int32_t destCapacity,
70 const UChar *src, int32_t srcLength,
79 class StringCharacterIterator;
80 class UnicodeStringAppendable;
94 #define US_INV icu::UnicodeString::kInvariant
113 #if defined(U_DECLARE_UTF16)
114 # define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)U_DECLARE_UTF16(cs), _length)
115 #elif U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && (U_CHARSET_FAMILY==U_ASCII_FAMILY || (U_SIZEOF_UCHAR == 2 && defined(U_WCHAR_IS_UTF16)))
116 # define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)L ## cs, _length)
117 #elif U_SIZEOF_UCHAR==1 && U_CHARSET_FAMILY==U_ASCII_FAMILY
118 # define UNICODE_STRING(cs, _length) icu::UnicodeString(TRUE, (const UChar *)cs, _length)
120 # define UNICODE_STRING(cs, _length) icu::UnicodeString(cs, _length, US_INV)
136 #define UNICODE_STRING_SIMPLE(cs) UNICODE_STRING(cs, -1)
145 #ifndef UNISTR_FROM_CHAR_EXPLICIT
146 # if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION)
148 # define UNISTR_FROM_CHAR_EXPLICIT explicit
151 # define UNISTR_FROM_CHAR_EXPLICIT
165 #ifndef UNISTR_FROM_STRING_EXPLICIT
166 # if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION)
168 # define UNISTR_FROM_STRING_EXPLICIT explicit
171 # define UNISTR_FROM_STRING_EXPLICIT
210 #ifndef UNISTR_OBJECT_SIZE
211 # define UNISTR_OBJECT_SIZE 64
401 inline int8_t compare(int32_t start,
422 inline int8_t compare(int32_t start,
426 int32_t srcLength)
const;
440 inline int8_t compare(
const UChar *srcChars,
441 int32_t srcLength)
const;
457 inline int8_t compare(int32_t start,
459 const UChar *srcChars)
const;
478 inline int8_t compare(int32_t start,
480 const UChar *srcChars,
482 int32_t srcLength)
const;
501 inline int8_t compareBetween(int32_t start,
505 int32_t srcLimit)
const;
524 inline int8_t compareCodePointOrder(
const UnicodeString& text)
const;
545 inline int8_t compareCodePointOrder(int32_t start,
570 inline int8_t compareCodePointOrder(int32_t start,
574 int32_t srcLength)
const;
594 inline int8_t compareCodePointOrder(
const UChar *srcChars,
595 int32_t srcLength)
const;
616 inline int8_t compareCodePointOrder(int32_t start,
618 const UChar *srcChars)
const;
641 inline int8_t compareCodePointOrder(int32_t start,
643 const UChar *srcChars,
645 int32_t srcLength)
const;
668 inline int8_t compareCodePointOrderBetween(int32_t start,
672 int32_t srcLimit)
const;
692 inline int8_t caseCompare(
const UnicodeString& text, uint32_t options)
const;
714 inline int8_t caseCompare(int32_t start,
717 uint32_t options)
const;
741 inline int8_t caseCompare(int32_t start,
746 uint32_t options)
const;
767 inline int8_t caseCompare(
const UChar *srcChars,
769 uint32_t options)
const;
791 inline int8_t caseCompare(int32_t start,
793 const UChar *srcChars,
794 uint32_t options)
const;
818 inline int8_t caseCompare(int32_t start,
820 const UChar *srcChars,
823 uint32_t options)
const;
847 inline int8_t caseCompareBetween(int32_t start,
852 uint32_t options)
const;
875 int32_t srcLength)
const;
885 inline UBool startsWith(
const UChar *srcChars,
886 int32_t srcLength)
const;
897 inline UBool startsWith(
const UChar *srcChars,
899 int32_t srcLength)
const;
922 int32_t srcLength)
const;
933 int32_t srcLength)
const;
947 int32_t srcLength)
const;
972 int32_t start)
const;
987 int32_t length)
const;
1009 int32_t length)
const;
1022 inline int32_t indexOf(
const UChar *srcChars,
1024 int32_t start)
const;
1038 inline int32_t indexOf(
const UChar *srcChars,
1041 int32_t length)
const;
1059 int32_t indexOf(
const UChar *srcChars,
1063 int32_t length)
const;
1072 inline int32_t indexOf(
UChar c)
const;
1082 inline int32_t indexOf(
UChar32 c)
const;
1092 inline int32_t indexOf(
UChar c,
1093 int32_t start)
const;
1104 inline int32_t indexOf(
UChar32 c,
1105 int32_t start)
const;
1117 inline int32_t indexOf(
UChar c,
1119 int32_t length)
const;
1132 inline int32_t indexOf(
UChar32 c,
1134 int32_t length)
const;
1144 inline int32_t lastIndexOf(
const UnicodeString& text)
const;
1156 int32_t start)
const;
1171 int32_t length)
const;
1193 int32_t length)
const;
1205 inline int32_t lastIndexOf(
const UChar *srcChars,
1207 int32_t start)
const;
1221 inline int32_t lastIndexOf(
const UChar *srcChars,
1224 int32_t length)
const;
1242 int32_t lastIndexOf(
const UChar *srcChars,
1246 int32_t length)
const;
1255 inline int32_t lastIndexOf(
UChar c)
const;
1265 inline int32_t lastIndexOf(
UChar32 c)
const;
1275 inline int32_t lastIndexOf(
UChar c,
1276 int32_t start)
const;
1287 inline int32_t lastIndexOf(
UChar32 c,
1288 int32_t start)
const;
1300 inline int32_t lastIndexOf(
UChar c,
1302 int32_t length)
const;
1315 inline int32_t lastIndexOf(
UChar32 c,
1317 int32_t length)
const;
1339 inline UChar operator[] (int32_t offset)
const;
1369 int32_t getChar32Start(int32_t offset)
const;
1387 int32_t getChar32Limit(int32_t offset)
const;
1439 int32_t moveIndex32(int32_t index, int32_t delta)
const;
1458 inline void extract(int32_t start,
1461 int32_t dstStart = 0)
const;
1485 extract(
UChar *dest, int32_t destCapacity,
1498 inline void extract(int32_t start,
1516 int32_t dstStart = 0)
const;
1552 int32_t extract(int32_t start,
1553 int32_t startLength,
1555 int32_t targetCapacity,
1556 enum EInvariant inv)
const;
1558 #if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION
1579 int32_t extract(int32_t start,
1580 int32_t startLength,
1582 uint32_t targetLength)
const;
1586 #if !UCONFIG_NO_CONVERSION
1613 inline int32_t extract(int32_t start,
1614 int32_t startLength,
1616 const char *codepage = 0)
const;
1647 int32_t extract(int32_t start,
1648 int32_t startLength,
1650 uint32_t targetLength,
1651 const char *codepage)
const;
1670 int32_t extract(
char *dest, int32_t destCapacity,
1716 #if U_HAVE_STD_STRING
1730 template<
typename StringClass>
1766 inline int32_t
length(
void)
const;
1782 countChar32(int32_t start=0, int32_t length=
INT32_MAX)
const;
1808 hasMoreChar32Than(int32_t start, int32_t length, int32_t number)
const;
1815 inline UBool isEmpty(
void)
const;
1826 inline int32_t getCapacity(
void)
const;
1835 inline int32_t hashCode(
void)
const;
1849 inline UBool isBogus(
void)
const;
1905 #ifndef U_HIDE_DRAFT_API
1906 #if U_HAVE_RVALUE_REFERENCES
1916 return moveFrom(src);
1929 UnicodeString &moveFrom(UnicodeString &src)
U_NOEXCEPT;
2065 int32_t textLength);
2088 int32_t buffCapacity);
2290 const UChar *srcChars,
2304 const UChar *srcChars,
2390 const UChar *srcChars,
2408 const UChar *srcChars,
2508 virtual void copy(int32_t start, int32_t limit, int32_t dest);
2621 UBool padLeading(int32_t targetLength,
2622 UChar padChar = 0x0020);
2635 UBool padTrailing(int32_t targetLength,
2636 UChar padChar = 0x0020);
2644 inline UBool truncate(int32_t targetLength);
2708 #if !UCONFIG_NO_BREAK_ITERATION
2864 UChar *getBuffer(int32_t minCapacity);
2886 void releaseBuffer(int32_t newLength=-1);
2918 inline const UChar *getBuffer()
const;
2953 const UChar *getTerminatedBuffer();
3019 int32_t textLength);
3045 int32_t textLength);
3067 #if U_CHARSET_IS_UTF8 || !UCONFIG_NO_CONVERSION
3098 UnicodeString(
const char *codepageData, int32_t dataLength);
3102 #if !UCONFIG_NO_CONVERSION
3121 UnicodeString(
const char *codepageData,
const char *codepage);
3140 UnicodeString(
const char *codepageData, int32_t dataLength,
const char *codepage);
3164 const char *src, int32_t srcLength,
3194 UnicodeString(
const char *src, int32_t length,
enum EInvariant inv);
3215 #ifndef U_HIDE_DRAFT_API
3216 #if U_HAVE_RVALUE_REFERENCES
3352 UChar32 unescapeAt(int32_t &offset)
const;
3359 static UClassID U_EXPORT2 getStaticClassID();
3402 toUTF8(int32_t start, int32_t len,
3403 char *target, int32_t capacity)
const;
3412 doCompare(int32_t start,
3416 int32_t srcLength)
const;
3418 int8_t doCompare(int32_t start,
3420 const UChar *srcChars,
3422 int32_t srcLength)
const;
3425 doCompareCodePointOrder(int32_t start,
3429 int32_t srcLength)
const;
3431 int8_t doCompareCodePointOrder(int32_t start,
3433 const UChar *srcChars,
3435 int32_t srcLength)
const;
3438 doCaseCompare(int32_t start,
3443 uint32_t options)
const;
3446 doCaseCompare(int32_t start,
3448 const UChar *srcChars,
3451 uint32_t options)
const;
3453 int32_t doIndexOf(
UChar c,
3455 int32_t length)
const;
3459 int32_t length)
const;
3461 int32_t doLastIndexOf(
UChar c,
3463 int32_t length)
const;
3465 int32_t doLastIndexOf(
UChar32 c,
3467 int32_t length)
const;
3469 void doExtract(int32_t start,
3472 int32_t dstStart)
const;
3474 inline void doExtract(int32_t start,
3478 inline UChar doCharAt(int32_t offset)
const;
3488 const UChar *srcChars,
3499 int32_t doHashCode(
void)
const;
3503 inline UChar* getArrayStart(
void);
3504 inline const UChar* getArrayStart(
void)
const;
3506 inline UBool hasShortLength()
const;
3507 inline int32_t getShortLength()
const;
3511 inline UBool isWritable()
const;
3514 inline UBool isBufferWritable()
const;
3517 inline void setZeroLength();
3518 inline void setShortLength(int32_t len);
3519 inline void setLength(int32_t len);
3520 inline void setToEmpty();
3521 inline void setArray(
UChar *array, int32_t len, int32_t capacity);
3528 UBool allocate(int32_t capacity);
3531 void releaseArray(
void);
3543 inline void pinIndex(int32_t& start)
const;
3544 inline void pinIndices(int32_t& start,
3545 int32_t& length)
const;
3547 #if !UCONFIG_NO_CONVERSION
3550 int32_t doExtract(int32_t start, int32_t length,
3551 char *dest, int32_t destCapacity,
3565 void doCodepageCreate(
const char *codepageData,
3567 const char *codepage);
3574 doCodepageCreate(
const char *codepageData,
3592 UBool cloneArrayIfNeeded(int32_t newCapacity = -1,
3593 int32_t growCapacity = -1,
3595 int32_t **pBufferToDelete = 0,
3608 int32_t removeRef(
void);
3609 int32_t refCount(
void)
const;
3619 kInvalidUChar=0xffff,
3626 kUsingStackBuffer=2,
3628 kBufferIsReadonly=8,
3631 kAllStorageFlags=0x1f,
3634 kLength1=1<<kLengthShift,
3635 kMaxShortLength=0x3ff,
3636 kLengthIsLarge=0xffe0,
3639 kShortString=kUsingStackBuffer,
3640 kLongString=kRefCounted,
3641 kReadonlyAlias=kBufferIsReadonly,
3647 union StackBufferOrFields;
3648 friend union StackBufferOrFields;
3691 union StackBufferOrFields {
3695 int16_t fLengthAndFlags;
3696 UChar fBuffer[US_STACKBUF_SIZE];
3699 int16_t fLengthAndFlags;
3718 operator+ (
const UnicodeString &s1,
const UnicodeString &s2);
3729 UnicodeString::pinIndex(int32_t& start)
const
3734 }
else if(start >
length()) {
3740 UnicodeString::pinIndices(int32_t& start,
3741 int32_t& _length)
const
3747 }
else if(start > len) {
3752 }
else if(_length > (len - start)) {
3753 _length = (len - start);
3758 UnicodeString::getArrayStart() {
3759 return (fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
3760 fUnion.fStackFields.fBuffer : fUnion.fFields.fArray;
3764 UnicodeString::getArrayStart()
const {
3765 return (fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
3766 fUnion.fStackFields.fBuffer : fUnion.fFields.fArray;
3774 UnicodeString::UnicodeString() {
3775 fUnion.fStackFields.fLengthAndFlags=kShortString;
3782 UnicodeString::hasShortLength()
const {
3783 return fUnion.fFields.fLengthAndFlags>=0;
3787 UnicodeString::getShortLength()
const {
3790 return fUnion.fFields.fLengthAndFlags>>kLengthShift;
3794 UnicodeString::length()
const {
3795 return hasShortLength() ? getShortLength() : fUnion.fFields.fLength;
3799 UnicodeString::getCapacity()
const {
3800 return (fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) ?
3801 US_STACKBUF_SIZE : fUnion.fFields.fCapacity;
3805 UnicodeString::hashCode()
const
3806 {
return doHashCode(); }
3809 UnicodeString::isBogus()
const
3810 {
return (
UBool)(fUnion.fFields.fLengthAndFlags & kIsBogus); }
3813 UnicodeString::isWritable()
const
3814 {
return (
UBool)!(fUnion.fFields.fLengthAndFlags&(kOpenGetBuffer|kIsBogus)); }
3817 UnicodeString::isBufferWritable()
const
3820 !(fUnion.fFields.fLengthAndFlags&(kOpenGetBuffer|kIsBogus|kBufferIsReadonly)) &&
3821 (!(fUnion.fFields.fLengthAndFlags&kRefCounted) || refCount()==1));
3824 inline const UChar *
3825 UnicodeString::getBuffer()
const {
3826 if(fUnion.fFields.fLengthAndFlags&(kIsBogus|kOpenGetBuffer)) {
3828 }
else if(fUnion.fFields.fLengthAndFlags&kUsingStackBuffer) {
3829 return fUnion.fStackFields.fBuffer;
3831 return fUnion.fFields.fArray;
3839 UnicodeString::doCompare(int32_t start,
3843 int32_t srcLength)
const
3846 return (int8_t)!isBogus();
3848 srcText.pinIndices(srcStart, srcLength);
3849 return doCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
3860 return !text.
isBogus() && len == textLength && doEquals(text, len);
3866 {
return (!
operator==(text)); }
3870 {
return doCompare(0,
length(), text, 0, text.
length()) == 1; }
3874 {
return doCompare(0,
length(), text, 0, text.
length()) == -1; }
3878 {
return doCompare(0,
length(), text, 0, text.
length()) != -1; }
3882 {
return doCompare(0,
length(), text, 0, text.
length()) != 1; }
3886 {
return doCompare(0,
length(), text, 0, text.
length()); }
3889 UnicodeString::compare(int32_t start,
3892 {
return doCompare(start, _length, srcText, 0, srcText.
length()); }
3895 UnicodeString::compare(
const UChar *srcChars,
3896 int32_t srcLength)
const
3897 {
return doCompare(0,
length(), srcChars, 0, srcLength); }
3900 UnicodeString::compare(int32_t start,
3904 int32_t srcLength)
const
3905 {
return doCompare(start, _length, srcText, srcStart, srcLength); }
3908 UnicodeString::compare(int32_t start,
3910 const UChar *srcChars)
const
3911 {
return doCompare(start, _length, srcChars, 0, _length); }
3914 UnicodeString::compare(int32_t start,
3916 const UChar *srcChars,
3918 int32_t srcLength)
const
3919 {
return doCompare(start, _length, srcChars, srcStart, srcLength); }
3922 UnicodeString::compareBetween(int32_t start,
3926 int32_t srcLimit)
const
3927 {
return doCompare(start, limit - start,
3928 srcText, srcStart, srcLimit - srcStart); }
3931 UnicodeString::doCompareCodePointOrder(int32_t start,
3935 int32_t srcLength)
const
3938 return (int8_t)!isBogus();
3940 srcText.pinIndices(srcStart, srcLength);
3941 return doCompareCodePointOrder(start, thisLength, srcText.getArrayStart(), srcStart, srcLength);
3947 {
return doCompareCodePointOrder(0,
length(), text, 0, text.
length()); }
3950 UnicodeString::compareCodePointOrder(int32_t start,
3953 {
return doCompareCodePointOrder(start, _length, srcText, 0, srcText.
length()); }
3956 UnicodeString::compareCodePointOrder(
const UChar *srcChars,
3957 int32_t srcLength)
const
3958 {
return doCompareCodePointOrder(0,
length(), srcChars, 0, srcLength); }
3961 UnicodeString::compareCodePointOrder(int32_t start,
3965 int32_t srcLength)
const
3966 {
return doCompareCodePointOrder(start, _length, srcText, srcStart, srcLength); }
3969 UnicodeString::compareCodePointOrder(int32_t start,
3971 const UChar *srcChars)
const
3972 {
return doCompareCodePointOrder(start, _length, srcChars, 0, _length); }
3975 UnicodeString::compareCodePointOrder(int32_t start,
3977 const UChar *srcChars,
3979 int32_t srcLength)
const
3980 {
return doCompareCodePointOrder(start, _length, srcChars, srcStart, srcLength); }
3983 UnicodeString::compareCodePointOrderBetween(int32_t start,
3987 int32_t srcLimit)
const
3988 {
return doCompareCodePointOrder(start, limit - start,
3989 srcText, srcStart, srcLimit - srcStart); }
3992 UnicodeString::doCaseCompare(int32_t start,
3997 uint32_t options)
const
4000 return (int8_t)!isBogus();
4002 srcText.pinIndices(srcStart, srcLength);
4003 return doCaseCompare(start, thisLength, srcText.getArrayStart(), srcStart, srcLength, options);
4009 return doCaseCompare(0,
length(), text, 0, text.
length(), options);
4013 UnicodeString::caseCompare(int32_t start,
4016 uint32_t options)
const {
4017 return doCaseCompare(start, _length, srcText, 0, srcText.
length(), options);
4021 UnicodeString::caseCompare(
const UChar *srcChars,
4023 uint32_t options)
const {
4024 return doCaseCompare(0,
length(), srcChars, 0, srcLength, options);
4028 UnicodeString::caseCompare(int32_t start,
4033 uint32_t options)
const {
4034 return doCaseCompare(start, _length, srcText, srcStart, srcLength, options);
4038 UnicodeString::caseCompare(int32_t start,
4040 const UChar *srcChars,
4041 uint32_t options)
const {
4042 return doCaseCompare(start, _length, srcChars, 0, _length, options);
4046 UnicodeString::caseCompare(int32_t start,
4048 const UChar *srcChars,
4051 uint32_t options)
const {
4052 return doCaseCompare(start, _length, srcChars, srcStart, srcLength, options);
4056 UnicodeString::caseCompareBetween(int32_t start,
4061 uint32_t options)
const {
4062 return doCaseCompare(start, limit - start, srcText, srcStart, srcLimit - srcStart, options);
4070 int32_t _length)
const
4073 srcText.pinIndices(srcStart, srcLength);
4075 return indexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
4083 {
return indexOf(text, 0, text.
length(), 0,
length()); }
4087 int32_t start)
const {
4089 return indexOf(text, 0, text.
length(), start,
length() - start);
4095 int32_t _length)
const
4096 {
return indexOf(text, 0, text.
length(), start, _length); }
4099 UnicodeString::indexOf(
const UChar *srcChars,
4101 int32_t start)
const {
4103 return indexOf(srcChars, 0, srcLength, start,
length() - start);
4107 UnicodeString::indexOf(
const UChar *srcChars,
4110 int32_t _length)
const
4111 {
return indexOf(srcChars, 0, srcLength, start, _length); }
4116 int32_t _length)
const
4117 {
return doIndexOf(c, start, _length); }
4122 int32_t _length)
const
4123 {
return doIndexOf(c, start, _length); }
4127 {
return doIndexOf(c, 0,
length()); }
4131 {
return indexOf(c, 0,
length()); }
4135 int32_t start)
const {
4137 return doIndexOf(c, start,
length() - start);
4142 int32_t start)
const {
4144 return indexOf(c, start,
length() - start);
4148 UnicodeString::lastIndexOf(
const UChar *srcChars,
4151 int32_t _length)
const
4152 {
return lastIndexOf(srcChars, 0, srcLength, start, _length); }
4155 UnicodeString::lastIndexOf(
const UChar *srcChars,
4157 int32_t start)
const {
4159 return lastIndexOf(srcChars, 0, srcLength, start,
length() - start);
4167 int32_t _length)
const
4170 srcText.pinIndices(srcStart, srcLength);
4172 return lastIndexOf(srcText.getArrayStart(), srcStart, srcLength, start, _length);
4181 int32_t _length)
const
4182 {
return lastIndexOf(text, 0, text.
length(), start, _length); }
4186 int32_t start)
const {
4188 return lastIndexOf(text, 0, text.
length(), start,
length() - start);
4193 {
return lastIndexOf(text, 0, text.
length(), 0,
length()); }
4198 int32_t _length)
const
4199 {
return doLastIndexOf(c, start, _length); }
4204 int32_t _length)
const {
4205 return doLastIndexOf(c, start, _length);
4209 UnicodeString::lastIndexOf(
UChar c)
const
4210 {
return doLastIndexOf(c, 0,
length()); }
4214 return lastIndexOf(c, 0,
length());
4219 int32_t start)
const {
4221 return doLastIndexOf(c, start,
length() - start);
4226 int32_t start)
const {
4228 return lastIndexOf(c, start,
length() - start);
4233 {
return compare(0, text.
length(), text, 0, text.
length()) == 0; }
4238 int32_t srcLength)
const
4239 {
return doCompare(0, srcLength, srcText, srcStart, srcLength) == 0; }
4242 UnicodeString::startsWith(
const UChar *srcChars, int32_t srcLength)
const {
4246 return doCompare(0, srcLength, srcChars, 0, srcLength) == 0;
4250 UnicodeString::startsWith(
const UChar *srcChars, int32_t srcStart, int32_t srcLength)
const {
4254 return doCompare(0, srcLength, srcChars, srcStart, srcLength) == 0;
4260 text, 0, text.
length()) == 0; }
4265 int32_t srcLength)
const {
4266 srcText.pinIndices(srcStart, srcLength);
4267 return doCompare(
length() - srcLength, srcLength,
4268 srcText, srcStart, srcLength) == 0;
4272 UnicodeString::endsWith(
const UChar *srcChars,
4273 int32_t srcLength)
const {
4277 return doCompare(
length() - srcLength, srcLength,
4278 srcChars, 0, srcLength) == 0;
4282 UnicodeString::endsWith(
const UChar *srcChars,
4284 int32_t srcLength)
const {
4286 srcLength =
u_strlen(srcChars + srcStart);
4288 return doCompare(
length() - srcLength, srcLength,
4289 srcChars, srcStart, srcLength) == 0;
4296 UnicodeString::replace(int32_t start,
4299 {
return doReplace(start, _length, srcText, 0, srcText.
length()); }
4302 UnicodeString::replace(int32_t start,
4307 {
return doReplace(start, _length, srcText, srcStart, srcLength); }
4310 UnicodeString::replace(int32_t start,
4312 const UChar *srcChars,
4314 {
return doReplace(start, _length, srcChars, 0, srcLength); }
4317 UnicodeString::replace(int32_t start,
4319 const UChar *srcChars,
4322 {
return doReplace(start, _length, srcChars, srcStart, srcLength); }
4325 UnicodeString::replace(int32_t start,
4328 {
return doReplace(start, _length, &srcChar, 0, 1); }
4331 UnicodeString::replaceBetween(int32_t start,
4334 {
return doReplace(start, limit - start, srcText, 0, srcText.
length()); }
4337 UnicodeString::replaceBetween(int32_t start,
4342 {
return doReplace(start, limit - start, srcText, srcStart, srcLimit - srcStart); }
4347 {
return findAndReplace(0,
length(), oldText, 0, oldText.
length(),
4348 newText, 0, newText.
length()); }
4351 UnicodeString::findAndReplace(int32_t start,
4355 {
return findAndReplace(start, _length, oldText, 0, oldText.
length(),
4356 newText, 0, newText.
length()); }
4362 UnicodeString::doExtract(int32_t start,
4365 { target.
replace(0, target.
length(), *
this, start, _length); }
4368 UnicodeString::extract(int32_t start,
4371 int32_t targetStart)
const
4372 { doExtract(start, _length, target, targetStart); }
4375 UnicodeString::extract(int32_t start,
4378 { doExtract(start, _length, target); }
4380 #if !UCONFIG_NO_CONVERSION
4383 UnicodeString::extract(int32_t start,
4386 const char *codepage)
const
4390 return extract(start, _length, dst, dst!=0 ? 0xffffffff : 0, codepage);
4396 UnicodeString::extractBetween(int32_t start,
4399 int32_t dstStart)
const {
4402 doExtract(start, limit - start, dst, dstStart);
4406 UnicodeString::tempSubStringBetween(int32_t start, int32_t limit)
const {
4407 return tempSubString(start, limit - start);
4411 UnicodeString::doCharAt(int32_t offset)
const
4413 if((uint32_t)offset < (uint32_t)
length()) {
4414 return getArrayStart()[offset];
4416 return kInvalidUChar;
4421 UnicodeString::charAt(int32_t offset)
const
4422 {
return doCharAt(offset); }
4425 UnicodeString::operator[] (int32_t offset)
const
4426 {
return doCharAt(offset); }
4429 UnicodeString::isEmpty()
const {
4431 return (fUnion.fFields.fLengthAndFlags>>kLengthShift) == 0;
4438 UnicodeString::setZeroLength() {
4439 fUnion.fFields.fLengthAndFlags &= kAllStorageFlags;
4443 UnicodeString::setShortLength(int32_t len) {
4445 fUnion.fFields.fLengthAndFlags =
4446 (int16_t)((fUnion.fFields.fLengthAndFlags & kAllStorageFlags) | (len << kLengthShift));
4450 UnicodeString::setLength(int32_t len) {
4451 if(len <= kMaxShortLength) {
4452 setShortLength(len);
4454 fUnion.fFields.fLengthAndFlags |= kLengthIsLarge;
4455 fUnion.fFields.fLength = len;
4460 UnicodeString::setToEmpty() {
4461 fUnion.fFields.fLengthAndFlags = kShortString;
4465 UnicodeString::setArray(
UChar *array, int32_t len, int32_t capacity) {
4467 fUnion.fFields.fArray = array;
4468 fUnion.fFields.fCapacity = capacity;
4471 inline UnicodeString&
4473 {
return doReplace(0,
length(), &ch, 0, 1); }
4477 {
return replace(0,
length(), ch); }
4485 return doReplace(0,
length(), srcText, srcStart, srcLength);
4493 srcText.pinIndex(srcStart);
4494 return doReplace(0,
length(), srcText, srcStart, srcText.
length() - srcStart);
4500 return copyFrom(srcText);
4504 UnicodeString::setTo(
const UChar *srcChars,
4508 return doReplace(0,
length(), srcChars, 0, srcLength);
4515 return doReplace(0,
length(), &srcChar, 0, 1);
4522 return replace(0,
length(), srcChar);
4529 {
return doAppend(srcText, srcStart, srcLength); }
4533 {
return doAppend(srcText, 0, srcText.
length()); }
4536 UnicodeString::append(
const UChar *srcChars,
4539 {
return doAppend(srcChars, srcStart, srcLength); }
4542 UnicodeString::append(
const UChar *srcChars,
4544 {
return doAppend(srcChars, 0, srcLength); }
4548 {
return doAppend(&srcChar, 0, 1); }
4552 {
return doAppend(&ch, 0, 1); }
4561 {
return doAppend(srcText, 0, srcText.
length()); }
4564 UnicodeString::insert(int32_t start,
4568 {
return doReplace(start, 0, srcText, srcStart, srcLength); }
4571 UnicodeString::insert(int32_t start,
4573 {
return doReplace(start, 0, srcText, 0, srcText.
length()); }
4576 UnicodeString::insert(int32_t start,
4577 const UChar *srcChars,
4580 {
return doReplace(start, 0, srcChars, srcStart, srcLength); }
4583 UnicodeString::insert(int32_t start,
4584 const UChar *srcChars,
4586 {
return doReplace(start, 0, srcChars, 0, srcLength); }
4589 UnicodeString::insert(int32_t start,
4591 {
return doReplace(start, 0, &srcChar, 0, 1); }
4594 UnicodeString::insert(int32_t start,
4596 {
return replace(start, 0, srcChar); }
4600 UnicodeString::remove()
4612 UnicodeString::remove(int32_t start,
4615 if(start <= 0 && _length ==
INT32_MAX) {
4619 return doReplace(start, _length,
NULL, 0, 0);
4623 UnicodeString::removeBetween(int32_t start,
4625 {
return doReplace(start, limit - start,
NULL, 0, 0); }
4628 UnicodeString::retainBetween(int32_t start, int32_t limit) {
4630 return doReplace(0, start,
NULL, 0, 0);
4634 UnicodeString::truncate(int32_t targetLength)
4636 if(isBogus() && targetLength == 0) {
4640 }
else if((uint32_t)targetLength < (uint32_t)
length()) {
4641 setLength(targetLength);
4649 UnicodeString::reverse()
4650 {
return doReverse(0,
length()); }
4653 UnicodeString::reverse(int32_t start,
4655 {
return doReverse(start, _length); }