aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/icu/common/ustrtrns.cpp
diff options
context:
space:
mode:
authorromankoshelev <romankoshelev@yandex-team.com>2023-08-14 19:51:50 +0300
committerromankoshelev <romankoshelev@yandex-team.com>2023-08-15 01:24:11 +0300
commitcfcd865e05c0d0525ea27d1e153a043b32a85138 (patch)
tree68d3b3b25271e8a4998505897a269ff7ce119b76 /contrib/libs/icu/common/ustrtrns.cpp
parentccb790c507bd5e8ffe2ef9886ce5ee0a7ce22a15 (diff)
downloadydb-cfcd865e05c0d0525ea27d1e153a043b32a85138.tar.gz
Update ICU to 73.2
Diffstat (limited to 'contrib/libs/icu/common/ustrtrns.cpp')
-rw-r--r--contrib/libs/icu/common/ustrtrns.cpp270
1 files changed, 135 insertions, 135 deletions
diff --git a/contrib/libs/icu/common/ustrtrns.cpp b/contrib/libs/icu/common/ustrtrns.cpp
index 5dc032c02f..244c111fc4 100644
--- a/contrib/libs/icu/common/ustrtrns.cpp
+++ b/contrib/libs/icu/common/ustrtrns.cpp
@@ -36,8 +36,8 @@
#include "ustr_imp.h"
#include "uassert.h"
-U_CAPI UChar* U_EXPORT2
-u_strFromUTF32WithSub(UChar *dest,
+U_CAPI char16_t* U_EXPORT2
+u_strFromUTF32WithSub(char16_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
const UChar32 *src,
@@ -46,29 +46,29 @@ u_strFromUTF32WithSub(UChar *dest,
UErrorCode *pErrorCode) {
const UChar32 *srcLimit;
UChar32 ch;
- UChar *destLimit;
- UChar *pDest;
+ char16_t *destLimit;
+ char16_t *pDest;
int32_t reqLength;
int32_t numSubstitutions;
/* args check */
if(U_FAILURE(*pErrorCode)){
- return NULL;
+ return nullptr;
}
- if( (src==NULL && srcLength!=0) || srcLength < -1 ||
- (destCapacity<0) || (dest == NULL && destCapacity > 0) ||
+ if( (src==nullptr && srcLength!=0) || srcLength < -1 ||
+ (destCapacity<0) || (dest == nullptr && destCapacity > 0) ||
subchar > 0x10ffff || U_IS_SURROGATE(subchar)
) {
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
- if(pNumSubstitutions != NULL) {
+ if(pNumSubstitutions != nullptr) {
*pNumSubstitutions = 0;
}
pDest = dest;
- destLimit = (dest!=NULL)?(dest + destCapacity):NULL;
+ destLimit = (dest!=nullptr)?(dest + destCapacity):nullptr;
reqLength = 0;
numSubstitutions = 0;
@@ -78,7 +78,7 @@ u_strFromUTF32WithSub(UChar *dest,
((uint32_t)ch < 0xd800 || (0xe000 <= ch && ch <= 0xffff))) {
++src;
if(pDest < destLimit) {
- *pDest++ = (UChar)ch;
+ *pDest++ = (char16_t)ch;
} else {
++reqLength;
}
@@ -89,7 +89,7 @@ u_strFromUTF32WithSub(UChar *dest,
while(*++srcLimit != 0) {}
}
} else {
- srcLimit = (src!=NULL)?(src + srcLength):NULL;
+ srcLimit = (src!=nullptr)?(src + srcLength):nullptr;
}
/* convert with length */
@@ -99,13 +99,13 @@ u_strFromUTF32WithSub(UChar *dest,
/* usually "loops" once; twice only for writing subchar */
if((uint32_t)ch < 0xd800 || (0xe000 <= ch && ch <= 0xffff)) {
if(pDest < destLimit) {
- *pDest++ = (UChar)ch;
+ *pDest++ = (char16_t)ch;
} else {
++reqLength;
}
break;
} else if(0x10000 <= ch && ch <= 0x10ffff) {
- if(pDest!=NULL && ((pDest + 2) <= destLimit)) {
+ if(pDest!=nullptr && ((pDest + 2) <= destLimit)) {
*pDest++ = U16_LEAD(ch);
*pDest++ = U16_TRAIL(ch);
} else {
@@ -115,18 +115,18 @@ u_strFromUTF32WithSub(UChar *dest,
} else if((ch = subchar) < 0) {
/* surrogate code point, or not a Unicode code point at all */
*pErrorCode = U_INVALID_CHAR_FOUND;
- return NULL;
+ return nullptr;
} else {
++numSubstitutions;
}
- } while(TRUE);
+ } while(true);
}
reqLength += (int32_t)(pDest - dest);
if(pDestLength) {
*pDestLength = reqLength;
}
- if(pNumSubstitutions != NULL) {
+ if(pNumSubstitutions != nullptr) {
*pNumSubstitutions = numSubstitutions;
}
@@ -136,8 +136,8 @@ u_strFromUTF32WithSub(UChar *dest,
return dest;
}
-U_CAPI UChar* U_EXPORT2
-u_strFromUTF32(UChar *dest,
+U_CAPI char16_t* U_EXPORT2
+u_strFromUTF32(char16_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
const UChar32 *src,
@@ -146,7 +146,7 @@ u_strFromUTF32(UChar *dest,
return u_strFromUTF32WithSub(
dest, destCapacity, pDestLength,
src, srcLength,
- U_SENTINEL, NULL,
+ U_SENTINEL, nullptr,
pErrorCode);
}
@@ -154,13 +154,13 @@ U_CAPI UChar32* U_EXPORT2
u_strToUTF32WithSub(UChar32 *dest,
int32_t destCapacity,
int32_t *pDestLength,
- const UChar *src,
+ const char16_t *src,
int32_t srcLength,
UChar32 subchar, int32_t *pNumSubstitutions,
UErrorCode *pErrorCode) {
- const UChar *srcLimit;
+ const char16_t *srcLimit;
UChar32 ch;
- UChar ch2;
+ char16_t ch2;
UChar32 *destLimit;
UChar32 *pDest;
int32_t reqLength;
@@ -168,22 +168,22 @@ u_strToUTF32WithSub(UChar32 *dest,
/* args check */
if(U_FAILURE(*pErrorCode)){
- return NULL;
+ return nullptr;
}
- if( (src==NULL && srcLength!=0) || srcLength < -1 ||
- (destCapacity<0) || (dest == NULL && destCapacity > 0) ||
+ if( (src==nullptr && srcLength!=0) || srcLength < -1 ||
+ (destCapacity<0) || (dest == nullptr && destCapacity > 0) ||
subchar > 0x10ffff || U_IS_SURROGATE(subchar)
) {
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
- if(pNumSubstitutions != NULL) {
+ if(pNumSubstitutions != nullptr) {
*pNumSubstitutions = 0;
}
pDest = dest;
- destLimit = (dest!=NULL)?(dest + destCapacity):NULL;
+ destLimit = (dest!=nullptr)?(dest + destCapacity):nullptr;
reqLength = 0;
numSubstitutions = 0;
@@ -203,7 +203,7 @@ u_strToUTF32WithSub(UChar32 *dest,
while(*++srcLimit != 0) {}
}
} else {
- srcLimit = (src!=NULL)?(src + srcLength):NULL;
+ srcLimit = (src!=nullptr)?(src + srcLength):nullptr;
}
/* convert with length */
@@ -217,7 +217,7 @@ u_strToUTF32WithSub(UChar32 *dest,
} else if((ch = subchar) < 0) {
/* unpaired surrogate */
*pErrorCode = U_INVALID_CHAR_FOUND;
- return NULL;
+ return nullptr;
} else {
++numSubstitutions;
}
@@ -232,7 +232,7 @@ u_strToUTF32WithSub(UChar32 *dest,
if(pDestLength) {
*pDestLength = reqLength;
}
- if(pNumSubstitutions != NULL) {
+ if(pNumSubstitutions != nullptr) {
*pNumSubstitutions = numSubstitutions;
}
@@ -246,18 +246,18 @@ U_CAPI UChar32* U_EXPORT2
u_strToUTF32(UChar32 *dest,
int32_t destCapacity,
int32_t *pDestLength,
- const UChar *src,
+ const char16_t *src,
int32_t srcLength,
UErrorCode *pErrorCode) {
return u_strToUTF32WithSub(
dest, destCapacity, pDestLength,
src, srcLength,
- U_SENTINEL, NULL,
+ U_SENTINEL, nullptr,
pErrorCode);
}
-U_CAPI UChar* U_EXPORT2
-u_strFromUTF8WithSub(UChar *dest,
+U_CAPI char16_t* U_EXPORT2
+u_strFromUTF8WithSub(char16_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
const char* src,
@@ -266,21 +266,21 @@ u_strFromUTF8WithSub(UChar *dest,
UErrorCode *pErrorCode){
/* args check */
if(U_FAILURE(*pErrorCode)) {
- return NULL;
+ return nullptr;
}
- if( (src==NULL && srcLength!=0) || srcLength < -1 ||
- (destCapacity<0) || (dest == NULL && destCapacity > 0) ||
+ if( (src==nullptr && srcLength!=0) || srcLength < -1 ||
+ (destCapacity<0) || (dest == nullptr && destCapacity > 0) ||
subchar > 0x10ffff || U_IS_SURROGATE(subchar)
) {
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
- if(pNumSubstitutions!=NULL) {
+ if(pNumSubstitutions!=nullptr) {
*pNumSubstitutions=0;
}
- UChar *pDest = dest;
- UChar *pDestLimit = dest+destCapacity;
+ char16_t *pDest = dest;
+ char16_t *pDestLimit = dest+destCapacity;
int32_t reqLength = 0;
int32_t numSubstitutions=0;
@@ -309,7 +309,7 @@ u_strFromUTF8WithSub(UChar *dest,
// modified copy of U8_NEXT()
++i;
if(U8_IS_SINGLE(c)) {
- *pDest++=(UChar)c;
+ *pDest++=(char16_t)c;
} else {
uint8_t __t1, __t2;
if( /* handle U+0800..U+FFFF inline */
@@ -328,9 +328,9 @@ u_strFromUTF8WithSub(UChar *dest,
(c)=utf8_nextCharSafeBody((const uint8_t *)src, &(i), -1, c, -1);
if(c<0 && (++numSubstitutions, c = subchar) < 0) {
*pErrorCode = U_INVALID_CHAR_FOUND;
- return NULL;
+ return nullptr;
} else if(c<=0xFFFF) {
- *(pDest++)=(UChar)c;
+ *(pDest++)=(char16_t)c;
} else {
*(pDest++)=U16_LEAD(c);
if(pDest<pDestLimit) {
@@ -368,7 +368,7 @@ u_strFromUTF8WithSub(UChar *dest,
(c)=utf8_nextCharSafeBody((const uint8_t *)src, &(i), -1, c, -1);
if(c<0 && (++numSubstitutions, c = subchar) < 0) {
*pErrorCode = U_INVALID_CHAR_FOUND;
- return NULL;
+ return nullptr;
}
reqLength += U16_LENGTH(c);
}
@@ -381,7 +381,7 @@ u_strFromUTF8WithSub(UChar *dest,
for(;;) {
/*
* Each iteration of the inner loop progresses by at most 3 UTF-8
- * bytes and one UChar, for most characters.
+ * bytes and one char16_t, for most characters.
* For supplementary code points (4 & 2), which are rare,
* there is an additional adjustment.
*/
@@ -402,7 +402,7 @@ u_strFromUTF8WithSub(UChar *dest,
// modified copy of U8_NEXT()
c = (uint8_t)src[i++];
if(U8_IS_SINGLE(c)) {
- *pDest++=(UChar)c;
+ *pDest++=(char16_t)c;
} else {
uint8_t __t1, __t2;
if( /* handle U+0800..U+FFFF inline */
@@ -433,9 +433,9 @@ u_strFromUTF8WithSub(UChar *dest,
(c)=utf8_nextCharSafeBody((const uint8_t *)src, &(i), srcLength, c, -1);
if(c<0 && (++numSubstitutions, c = subchar) < 0) {
*pErrorCode = U_INVALID_CHAR_FOUND;
- return NULL;
+ return nullptr;
} else if(c<=0xFFFF) {
- *(pDest++)=(UChar)c;
+ *(pDest++)=(char16_t)c;
} else {
*(pDest++)=U16_LEAD(c);
*(pDest++)=U16_TRAIL(c);
@@ -449,7 +449,7 @@ u_strFromUTF8WithSub(UChar *dest,
// modified copy of U8_NEXT()
c = (uint8_t)src[i++];
if(U8_IS_SINGLE(c)) {
- *pDest++=(UChar)c;
+ *pDest++=(char16_t)c;
} else {
uint8_t __t1, __t2;
if( /* handle U+0800..U+FFFF inline */
@@ -470,9 +470,9 @@ u_strFromUTF8WithSub(UChar *dest,
(c)=utf8_nextCharSafeBody((const uint8_t *)src, &(i), srcLength, c, -1);
if(c<0 && (++numSubstitutions, c = subchar) < 0) {
*pErrorCode = U_INVALID_CHAR_FOUND;
- return NULL;
+ return nullptr;
} else if(c<=0xFFFF) {
- *(pDest++)=(UChar)c;
+ *(pDest++)=(char16_t)c;
} else {
*(pDest++)=U16_LEAD(c);
if(pDest<pDestLimit) {
@@ -512,7 +512,7 @@ u_strFromUTF8WithSub(UChar *dest,
(c)=utf8_nextCharSafeBody((const uint8_t *)src, &(i), srcLength, c, -1);
if(c<0 && (++numSubstitutions, c = subchar) < 0) {
*pErrorCode = U_INVALID_CHAR_FOUND;
- return NULL;
+ return nullptr;
}
reqLength += U16_LENGTH(c);
}
@@ -522,7 +522,7 @@ u_strFromUTF8WithSub(UChar *dest,
reqLength+=(int32_t)(pDest - dest);
- if(pNumSubstitutions!=NULL) {
+ if(pNumSubstitutions!=nullptr) {
*pNumSubstitutions=numSubstitutions;
}
@@ -536,8 +536,8 @@ u_strFromUTF8WithSub(UChar *dest,
return dest;
}
-U_CAPI UChar* U_EXPORT2
-u_strFromUTF8(UChar *dest,
+U_CAPI char16_t* U_EXPORT2
+u_strFromUTF8(char16_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
const char* src,
@@ -546,37 +546,37 @@ u_strFromUTF8(UChar *dest,
return u_strFromUTF8WithSub(
dest, destCapacity, pDestLength,
src, srcLength,
- U_SENTINEL, NULL,
+ U_SENTINEL, nullptr,
pErrorCode);
}
-U_CAPI UChar * U_EXPORT2
-u_strFromUTF8Lenient(UChar *dest,
+U_CAPI char16_t * U_EXPORT2
+u_strFromUTF8Lenient(char16_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
const char *src,
int32_t srcLength,
UErrorCode *pErrorCode) {
- UChar *pDest = dest;
+ char16_t *pDest = dest;
UChar32 ch;
int32_t reqLength = 0;
uint8_t* pSrc = (uint8_t*) src;
/* args check */
if(U_FAILURE(*pErrorCode)){
- return NULL;
+ return nullptr;
}
- if( (src==NULL && srcLength!=0) || srcLength < -1 ||
- (destCapacity<0) || (dest == NULL && destCapacity > 0)
+ if( (src==nullptr && srcLength!=0) || srcLength < -1 ||
+ (destCapacity<0) || (dest == nullptr && destCapacity > 0)
) {
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
if(srcLength < 0) {
/* Transform a NUL-terminated string. */
- UChar *pDestLimit = (dest!=NULL)?(dest+destCapacity):NULL;
+ char16_t *pDestLimit = (dest!=nullptr)?(dest+destCapacity):nullptr;
uint8_t t1, t2, t3; /* trail bytes */
while(((ch = *pSrc) != 0) && (pDest < pDestLimit)) {
@@ -586,21 +586,21 @@ u_strFromUTF8Lenient(UChar *dest,
* a single-byte sequence for better character boundary
* resynchronization after illegal sequences.
*/
- *pDest++=(UChar)ch;
+ *pDest++=(char16_t)ch;
++pSrc;
continue;
} else if(ch < 0xe0) { /* U+0080..U+07FF */
if((t1 = pSrc[1]) != 0) {
/* 0x3080 = (0xc0 << 6) + 0x80 */
- *pDest++ = (UChar)((ch << 6) + t1 - 0x3080);
+ *pDest++ = (char16_t)((ch << 6) + t1 - 0x3080);
pSrc += 2;
continue;
}
} else if(ch < 0xf0) { /* U+0800..U+FFFF */
if((t1 = pSrc[1]) != 0 && (t2 = pSrc[2]) != 0) {
- /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (UChar) */
+ /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (char16_t) */
/* 0x2080 = (0x80 << 6) + 0x80 */
- *pDest++ = (UChar)((ch << 12) + (t1 << 6) + t2 - 0x2080);
+ *pDest++ = (char16_t)((ch << 12) + (t1 << 6) + t2 - 0x2080);
pSrc += 3;
continue;
}
@@ -662,7 +662,7 @@ u_strFromUTF8Lenient(UChar *dest,
break;
}
} else /* srcLength >= 0 */ {
- const uint8_t *pSrcLimit = (pSrc!=NULL)?(pSrc + srcLength):NULL;
+ const uint8_t *pSrcLimit = (pSrc!=nullptr)?(pSrc + srcLength):nullptr;
/*
* This function requires that if srcLength is given, then it must be
@@ -670,11 +670,11 @@ u_strFromUTF8Lenient(UChar *dest,
* destination buffer overflow in the loop.
*/
if(destCapacity < srcLength) {
- if(pDestLength != NULL) {
+ if(pDestLength != nullptr) {
*pDestLength = srcLength; /* this likely overestimates the true destLength! */
}
*pErrorCode = U_BUFFER_OVERFLOW_ERROR;
- return NULL;
+ return nullptr;
}
if((pSrcLimit - pSrc) >= 4) {
@@ -689,15 +689,15 @@ u_strFromUTF8Lenient(UChar *dest,
* a single-byte sequence for better character boundary
* resynchronization after illegal sequences.
*/
- *pDest++=(UChar)ch;
+ *pDest++=(char16_t)ch;
} else if(ch < 0xe0) { /* U+0080..U+07FF */
/* 0x3080 = (0xc0 << 6) + 0x80 */
- *pDest++ = (UChar)((ch << 6) + *pSrc++ - 0x3080);
+ *pDest++ = (char16_t)((ch << 6) + *pSrc++ - 0x3080);
} else if(ch < 0xf0) { /* U+0800..U+FFFF */
- /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (UChar) */
+ /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (char16_t) */
/* 0x2080 = (0x80 << 6) + 0x80 */
ch = (ch << 12) + (*pSrc++ << 6);
- *pDest++ = (UChar)(ch + *pSrc++ - 0x2080);
+ *pDest++ = (char16_t)(ch + *pSrc++ - 0x2080);
} else /* f0..f4 */ { /* U+10000..U+10FFFF */
/* 0x3c82080 = (0xf0 << 18) + (0x80 << 12) + (0x80 << 6) + 0x80 */
ch = (ch << 18) + (*pSrc++ << 12);
@@ -719,20 +719,20 @@ u_strFromUTF8Lenient(UChar *dest,
* a single-byte sequence for better character boundary
* resynchronization after illegal sequences.
*/
- *pDest++=(UChar)ch;
+ *pDest++=(char16_t)ch;
continue;
} else if(ch < 0xe0) { /* U+0080..U+07FF */
if(pSrc < pSrcLimit) {
/* 0x3080 = (0xc0 << 6) + 0x80 */
- *pDest++ = (UChar)((ch << 6) + *pSrc++ - 0x3080);
+ *pDest++ = (char16_t)((ch << 6) + *pSrc++ - 0x3080);
continue;
}
} else if(ch < 0xf0) { /* U+0800..U+FFFF */
if((pSrcLimit - pSrc) >= 2) {
- /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (UChar) */
+ /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (char16_t) */
/* 0x2080 = (0x80 << 6) + 0x80 */
ch = (ch << 12) + (*pSrc++ << 6);
- *pDest++ = (UChar)(ch + *pSrc++ - 0x2080);
+ *pDest++ = (char16_t)(ch + *pSrc++ - 0x2080);
pSrc += 3;
continue;
}
@@ -793,30 +793,30 @@ U_CAPI char* U_EXPORT2
u_strToUTF8WithSub(char *dest,
int32_t destCapacity,
int32_t *pDestLength,
- const UChar *pSrc,
+ const char16_t *pSrc,
int32_t srcLength,
UChar32 subchar, int32_t *pNumSubstitutions,
UErrorCode *pErrorCode){
int32_t reqLength=0;
uint32_t ch=0,ch2=0;
uint8_t *pDest = (uint8_t *)dest;
- uint8_t *pDestLimit = (pDest!=NULL)?(pDest + destCapacity):NULL;
+ uint8_t *pDestLimit = (pDest!=nullptr)?(pDest + destCapacity):nullptr;
int32_t numSubstitutions;
/* args check */
if(U_FAILURE(*pErrorCode)){
- return NULL;
+ return nullptr;
}
- if( (pSrc==NULL && srcLength!=0) || srcLength < -1 ||
- (destCapacity<0) || (dest == NULL && destCapacity > 0) ||
+ if( (pSrc==nullptr && srcLength!=0) || srcLength < -1 ||
+ (destCapacity<0) || (dest == nullptr && destCapacity > 0) ||
subchar > 0x10ffff || U_IS_SURROGATE(subchar)
) {
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
- if(pNumSubstitutions!=NULL) {
+ if(pNumSubstitutions!=nullptr) {
*pNumSubstitutions=0;
}
numSubstitutions=0;
@@ -861,7 +861,7 @@ u_strToUTF8WithSub(char *dest,
} else {
/* Unicode 3.2 forbids surrogate code points in UTF-8 */
*pErrorCode = U_INVALID_CHAR_FOUND;
- return NULL;
+ return nullptr;
}
length = U8_LENGTH(ch);
@@ -890,18 +890,18 @@ u_strToUTF8WithSub(char *dest,
} else {
/* Unicode 3.2 forbids surrogate code points in UTF-8 */
*pErrorCode = U_INVALID_CHAR_FOUND;
- return NULL;
+ return nullptr;
}
}
} else {
- const UChar *pSrcLimit = (pSrc!=NULL)?(pSrc+srcLength):NULL;
+ const char16_t *pSrcLimit = (pSrc!=nullptr)?(pSrc+srcLength):nullptr;
int32_t count;
/* Faster loop without ongoing checking for pSrcLimit and pDestLimit. */
for(;;) {
/*
* Each iteration of the inner loop progresses by at most 3 UTF-8
- * bytes and one UChar, for most characters.
+ * bytes and one char16_t, for most characters.
* For supplementary code points (4 & 2), which are rare,
* there is an additional adjustment.
*/
@@ -955,7 +955,7 @@ u_strToUTF8WithSub(char *dest,
++numSubstitutions;
} else {
*pErrorCode = U_INVALID_CHAR_FOUND;
- return NULL;
+ return nullptr;
}
/* convert and append*/
@@ -1003,7 +1003,7 @@ u_strToUTF8WithSub(char *dest,
} else {
/* Unicode 3.2 forbids surrogate code points in UTF-8 */
*pErrorCode = U_INVALID_CHAR_FOUND;
- return NULL;
+ return nullptr;
}
length = U8_LENGTH(ch);
@@ -1033,14 +1033,14 @@ u_strToUTF8WithSub(char *dest,
} else {
/* Unicode 3.2 forbids surrogate code points in UTF-8 */
*pErrorCode = U_INVALID_CHAR_FOUND;
- return NULL;
+ return nullptr;
}
}
}
reqLength+=(int32_t)(pDest - (uint8_t *)dest);
- if(pNumSubstitutions!=NULL) {
+ if(pNumSubstitutions!=nullptr) {
*pNumSubstitutions=numSubstitutions;
}
@@ -1057,19 +1057,19 @@ U_CAPI char* U_EXPORT2
u_strToUTF8(char *dest,
int32_t destCapacity,
int32_t *pDestLength,
- const UChar *pSrc,
+ const char16_t *pSrc,
int32_t srcLength,
UErrorCode *pErrorCode){
return u_strToUTF8WithSub(
dest, destCapacity, pDestLength,
pSrc, srcLength,
- U_SENTINEL, NULL,
+ U_SENTINEL, nullptr,
pErrorCode);
}
-U_CAPI UChar* U_EXPORT2
+U_CAPI char16_t* U_EXPORT2
u_strFromJavaModifiedUTF8WithSub(
- UChar *dest,
+ char16_t *dest,
int32_t destCapacity,
int32_t *pDestLength,
const char *src,
@@ -1078,21 +1078,21 @@ u_strFromJavaModifiedUTF8WithSub(
UErrorCode *pErrorCode) {
/* args check */
if(U_FAILURE(*pErrorCode)) {
- return NULL;
+ return nullptr;
}
- if( (src==NULL && srcLength!=0) || srcLength < -1 ||
- (dest==NULL && destCapacity!=0) || destCapacity<0 ||
+ if( (src==nullptr && srcLength!=0) || srcLength < -1 ||
+ (dest==nullptr && destCapacity!=0) || destCapacity<0 ||
subchar > 0x10ffff || U_IS_SURROGATE(subchar)
) {
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
- if(pNumSubstitutions!=NULL) {
+ if(pNumSubstitutions!=nullptr) {
*pNumSubstitutions=0;
}
- UChar *pDest = dest;
- UChar *pDestLimit = dest+destCapacity;
+ char16_t *pDest = dest;
+ char16_t *pDestLimit = dest+destCapacity;
int32_t reqLength = 0;
int32_t numSubstitutions=0;
@@ -1103,7 +1103,7 @@ u_strFromJavaModifiedUTF8WithSub(
*/
UChar32 c;
while(((c = (uint8_t)*src) != 0) && c <= 0x7f && (pDest < pDestLimit)) {
- *pDest++=(UChar)c;
+ *pDest++=(char16_t)c;
++src;
}
if(c == 0) {
@@ -1140,7 +1140,7 @@ u_strFromJavaModifiedUTF8WithSub(
}
/*
* Each iteration of the inner loop progresses by at most 3 UTF-8
- * bytes and one UChar.
+ * bytes and one char16_t.
*/
if(subchar > 0xFFFF) {
break;
@@ -1159,7 +1159,7 @@ u_strFromJavaModifiedUTF8WithSub(
do {
ch = (uint8_t)src[i++];
if(U8_IS_SINGLE(ch)) {
- *pDest++=(UChar)ch;
+ *pDest++=(char16_t)ch;
} else {
if(ch >= 0xe0) {
if( /* handle U+0000..U+FFFF inline */
@@ -1167,8 +1167,8 @@ u_strFromJavaModifiedUTF8WithSub(
(t1 = (uint8_t)(src[i] - 0x80)) <= 0x3f &&
(t2 = (uint8_t)(src[i+1] - 0x80)) <= 0x3f
) {
- /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (UChar) */
- *pDest++ = (UChar)((ch << 12) | (t1 << 6) | t2);
+ /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (char16_t) */
+ *pDest++ = (char16_t)((ch << 12) | (t1 << 6) | t2);
i += 2;
continue;
}
@@ -1177,7 +1177,7 @@ u_strFromJavaModifiedUTF8WithSub(
ch >= 0xc0 &&
(t1 = (uint8_t)(src[i] - 0x80)) <= 0x3f
) {
- *pDest++ = (UChar)(((ch & 0x1f) << 6) | t1);
+ *pDest++ = (char16_t)(((ch & 0x1f) << 6) | t1);
++i;
continue;
}
@@ -1185,7 +1185,7 @@ u_strFromJavaModifiedUTF8WithSub(
if(subchar < 0) {
*pErrorCode = U_INVALID_CHAR_FOUND;
- return NULL;
+ return nullptr;
} else if(subchar > 0xffff && --count == 0) {
/*
* We need to write two UChars, adjusted count for that,
@@ -1197,7 +1197,7 @@ u_strFromJavaModifiedUTF8WithSub(
/* function call for error cases */
utf8_nextCharSafeBody((const uint8_t *)src, &(i), srcLength, ch, -1);
++numSubstitutions;
- *(pDest++)=(UChar)subchar;
+ *(pDest++)=(char16_t)subchar;
}
}
} while(--count > 0);
@@ -1206,7 +1206,7 @@ u_strFromJavaModifiedUTF8WithSub(
while(i < srcLength && (pDest < pDestLimit)) {
ch = (uint8_t)src[i++];
if(U8_IS_SINGLE(ch)){
- *pDest++=(UChar)ch;
+ *pDest++=(char16_t)ch;
} else {
if(ch >= 0xe0) {
if( /* handle U+0000..U+FFFF inline */
@@ -1215,8 +1215,8 @@ u_strFromJavaModifiedUTF8WithSub(
(t1 = (uint8_t)(src[i] - 0x80)) <= 0x3f &&
(t2 = (uint8_t)(src[i+1] - 0x80)) <= 0x3f
) {
- /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (UChar) */
- *pDest++ = (UChar)((ch << 12) | (t1 << 6) | t2);
+ /* no need for (ch & 0xf) because the upper bits are truncated after <<12 in the cast to (char16_t) */
+ *pDest++ = (char16_t)((ch << 12) | (t1 << 6) | t2);
i += 2;
continue;
}
@@ -1226,7 +1226,7 @@ u_strFromJavaModifiedUTF8WithSub(
i < srcLength &&
(t1 = (uint8_t)(src[i] - 0x80)) <= 0x3f
) {
- *pDest++ = (UChar)(((ch & 0x1f) << 6) | t1);
+ *pDest++ = (char16_t)(((ch & 0x1f) << 6) | t1);
++i;
continue;
}
@@ -1234,13 +1234,13 @@ u_strFromJavaModifiedUTF8WithSub(
if(subchar < 0) {
*pErrorCode = U_INVALID_CHAR_FOUND;
- return NULL;
+ return nullptr;
} else {
/* function call for error cases */
utf8_nextCharSafeBody((const uint8_t *)src, &(i), srcLength, ch, -1);
++numSubstitutions;
if(subchar<=0xFFFF) {
- *(pDest++)=(UChar)subchar;
+ *(pDest++)=(char16_t)subchar;
} else {
*(pDest++)=U16_LEAD(subchar);
if(pDest<pDestLimit) {
@@ -1285,7 +1285,7 @@ u_strFromJavaModifiedUTF8WithSub(
if(subchar < 0) {
*pErrorCode = U_INVALID_CHAR_FOUND;
- return NULL;
+ return nullptr;
} else {
/* function call for error cases */
utf8_nextCharSafeBody((const uint8_t *)src, &(i), srcLength, ch, -1);
@@ -1295,7 +1295,7 @@ u_strFromJavaModifiedUTF8WithSub(
}
}
- if(pNumSubstitutions!=NULL) {
+ if(pNumSubstitutions!=nullptr) {
*pNumSubstitutions=numSubstitutions;
}
@@ -1314,26 +1314,26 @@ u_strToJavaModifiedUTF8(
char *dest,
int32_t destCapacity,
int32_t *pDestLength,
- const UChar *src,
+ const char16_t *src,
int32_t srcLength,
UErrorCode *pErrorCode) {
int32_t reqLength=0;
uint32_t ch=0;
- uint8_t *pDest = (uint8_t *)dest;
- uint8_t *pDestLimit = pDest + destCapacity;
- const UChar *pSrcLimit;
+ const char16_t *pSrcLimit;
int32_t count;
/* args check */
if(U_FAILURE(*pErrorCode)){
- return NULL;
+ return nullptr;
}
- if( (src==NULL && srcLength!=0) || srcLength < -1 ||
- (dest==NULL && destCapacity!=0) || destCapacity<0
+ if( (src==nullptr && srcLength!=0) || srcLength < -1 ||
+ (dest==nullptr && destCapacity!=0) || destCapacity<0
) {
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
- return NULL;
+ return nullptr;
}
+ uint8_t *pDest = (uint8_t *)dest;
+ uint8_t *pDestLimit = pDest + destCapacity;
if(srcLength==-1) {
/* Convert NUL-terminated ASCII, then find the string length. */
@@ -1355,13 +1355,13 @@ u_strToJavaModifiedUTF8(
}
/* Faster loop without ongoing checking for pSrcLimit and pDestLimit. */
- pSrcLimit = (src!=NULL)?(src+srcLength):NULL;
+ pSrcLimit = (src!=nullptr)?(src+srcLength):nullptr;
for(;;) {
count = (int32_t)(pDestLimit - pDest);
srcLength = (int32_t)(pSrcLimit - src);
if(count >= srcLength && srcLength > 0 && *src <= 0x7f) {
/* fast ASCII loop */
- const UChar *prevSrc = src;
+ const char16_t *prevSrc = src;
int32_t delta;
while(src < pSrcLimit && (ch = *src) <= 0x7f && ch != 0) {
*pDest++=(uint8_t)ch;
@@ -1373,7 +1373,7 @@ u_strToJavaModifiedUTF8(
}
/*
* Each iteration of the inner loop progresses by at most 3 UTF-8
- * bytes and one UChar.
+ * bytes and one char16_t.
*/
count /= 3;
if(count > srcLength) {