2001-09-18 03:41:09 +00:00
|
|
|
/*
|
|
|
|
******************************************************************************
|
|
|
|
*
|
2004-09-07 17:49:59 +00:00
|
|
|
* Copyright (C) 2001-2004, International Business Machines
|
2001-09-18 03:41:09 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* File ustrtrns.c
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
*
|
|
|
|
* Date Name Description
|
|
|
|
* 9/10/2001 Ram Creation.
|
|
|
|
******************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* u_strTo* and u_strFrom* APIs
|
2004-09-07 17:49:59 +00:00
|
|
|
* WCS functions moved to ustr_wcs.c for better modularization
|
2001-09-18 03:41:09 +00:00
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "unicode/putil.h"
|
|
|
|
#include "unicode/ustring.h"
|
|
|
|
#include "cstring.h"
|
|
|
|
#include "cmemory.h"
|
|
|
|
#include "ustr_imp.h"
|
|
|
|
|
|
|
|
U_CAPI UChar* U_EXPORT2
|
|
|
|
u_strFromUTF32(UChar *dest,
|
|
|
|
int32_t destCapacity,
|
|
|
|
int32_t *pDestLength,
|
2001-10-05 23:13:25 +00:00
|
|
|
const UChar32 *src,
|
2001-09-18 03:41:09 +00:00
|
|
|
int32_t srcLength,
|
2001-10-05 23:13:25 +00:00
|
|
|
UErrorCode *pErrorCode)
|
|
|
|
{
|
2001-09-18 03:41:09 +00:00
|
|
|
int32_t reqLength = 0;
|
|
|
|
uint32_t ch =0;
|
|
|
|
UChar *pDestLimit =dest+destCapacity;
|
|
|
|
UChar *pDest = dest;
|
2001-10-05 23:13:25 +00:00
|
|
|
const uint32_t *pSrc = (const uint32_t *)src;
|
|
|
|
|
2001-09-18 03:41:09 +00:00
|
|
|
/* args check */
|
2001-11-30 05:20:18 +00:00
|
|
|
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)){
|
2001-09-18 03:41:09 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-07-24 23:23:19 +00:00
|
|
|
if((src==NULL) || (srcLength < -1) || (destCapacity<0) || (!dest && destCapacity > 0)){
|
2001-09-18 03:41:09 +00:00
|
|
|
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if the source is null terminated */
|
|
|
|
if(srcLength == -1 ){
|
2001-11-30 05:20:18 +00:00
|
|
|
while(((ch=*pSrc)!=0) && (pDest < pDestLimit)){
|
|
|
|
++pSrc;
|
|
|
|
if(ch<=0xFFFF){
|
|
|
|
*(pDest++)=(UChar)ch;
|
|
|
|
}else if(ch<=0x10ffff){
|
|
|
|
*(pDest++)=UTF16_LEAD(ch);
|
|
|
|
if(pDest<pDestLimit){
|
|
|
|
*(pDest++)=UTF16_TRAIL(ch);
|
2001-09-18 03:41:09 +00:00
|
|
|
}else{
|
2001-11-30 05:20:18 +00:00
|
|
|
reqLength++;
|
|
|
|
break;
|
2001-09-18 03:41:09 +00:00
|
|
|
}
|
|
|
|
}else{
|
2001-11-30 05:20:18 +00:00
|
|
|
*pErrorCode = U_INVALID_CHAR_FOUND;
|
|
|
|
return NULL;
|
2001-09-18 03:41:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
while((ch=*pSrc++) != 0){
|
|
|
|
reqLength+=UTF_CHAR_LENGTH(ch);
|
|
|
|
}
|
|
|
|
}else{
|
2001-10-05 23:13:25 +00:00
|
|
|
const uint32_t* pSrcLimit = ((const uint32_t*)pSrc) + srcLength;
|
2001-11-30 22:15:36 +00:00
|
|
|
while((pSrc < pSrcLimit) && (pDest < pDestLimit)){
|
2001-11-30 05:20:18 +00:00
|
|
|
ch = *pSrc++;
|
|
|
|
if(ch<=0xFFFF){
|
|
|
|
*(pDest++)=(UChar)ch;
|
|
|
|
}else if(ch<=0x10FFFF){
|
|
|
|
*(pDest++)=UTF16_LEAD(ch);
|
|
|
|
if(pDest<pDestLimit){
|
|
|
|
*(pDest++)=UTF16_TRAIL(ch);
|
2001-09-18 03:41:09 +00:00
|
|
|
}else{
|
2001-11-30 05:20:18 +00:00
|
|
|
reqLength++;
|
|
|
|
break;
|
2001-09-18 03:41:09 +00:00
|
|
|
}
|
|
|
|
}else{
|
2001-11-30 05:20:18 +00:00
|
|
|
*pErrorCode = U_INVALID_CHAR_FOUND;
|
|
|
|
return NULL;
|
2001-09-18 03:41:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
while(pSrc <pSrcLimit){
|
|
|
|
ch = *pSrc++;
|
|
|
|
reqLength+=UTF_CHAR_LENGTH(ch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-30 22:15:36 +00:00
|
|
|
reqLength += pDest - dest;
|
2001-09-18 03:41:09 +00:00
|
|
|
if(pDestLength){
|
|
|
|
*pDestLength = reqLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Terminate the buffer */
|
|
|
|
u_terminateUChars(dest,destCapacity,reqLength,pErrorCode);
|
|
|
|
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-05 23:13:25 +00:00
|
|
|
U_CAPI UChar32* U_EXPORT2
|
|
|
|
u_strToUTF32(UChar32 *dest,
|
2001-09-18 03:41:09 +00:00
|
|
|
int32_t destCapacity,
|
|
|
|
int32_t *pDestLength,
|
|
|
|
const UChar *src,
|
|
|
|
int32_t srcLength,
|
2001-10-05 23:13:25 +00:00
|
|
|
UErrorCode *pErrorCode)
|
|
|
|
{
|
2001-09-18 03:41:09 +00:00
|
|
|
const UChar* pSrc = src;
|
2001-11-30 05:20:18 +00:00
|
|
|
const UChar* pSrcLimit;
|
2001-09-18 03:41:09 +00:00
|
|
|
int32_t reqLength=0;
|
|
|
|
uint32_t ch=0;
|
2001-10-05 23:13:25 +00:00
|
|
|
uint32_t *pDest = (uint32_t *)dest;
|
|
|
|
uint32_t *pDestLimit = pDest + destCapacity;
|
2001-11-30 05:20:18 +00:00
|
|
|
UChar ch2=0;
|
2001-09-18 03:41:09 +00:00
|
|
|
|
|
|
|
/* args check */
|
2001-11-30 05:20:18 +00:00
|
|
|
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)){
|
2001-09-18 03:41:09 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-11-30 05:20:18 +00:00
|
|
|
|
2003-07-24 23:23:19 +00:00
|
|
|
if((src==NULL) || (srcLength < -1) || (destCapacity<0) || (!dest && destCapacity > 0)){
|
2001-09-18 03:41:09 +00:00
|
|
|
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-11-30 05:20:18 +00:00
|
|
|
if(srcLength==-1) {
|
|
|
|
while((ch=*pSrc)!=0 && pDest!=pDestLimit) {
|
|
|
|
++pSrc;
|
|
|
|
/*need not check for NUL because NUL fails UTF_IS_TRAIL() anyway*/
|
|
|
|
if(UTF_IS_LEAD(ch) && UTF_IS_TRAIL(ch2=*pSrc)) {
|
|
|
|
++pSrc;
|
|
|
|
ch=UTF16_GET_PAIR_VALUE(ch, ch2);
|
2001-09-18 03:41:09 +00:00
|
|
|
}
|
2001-11-30 05:20:18 +00:00
|
|
|
*(pDest++)= ch;
|
2001-09-18 03:41:09 +00:00
|
|
|
}
|
2001-11-30 05:20:18 +00:00
|
|
|
while((ch=*pSrc++)!=0) {
|
|
|
|
if(UTF_IS_LEAD(ch) && UTF_IS_TRAIL(ch2=*pSrc)) {
|
|
|
|
++pSrc;
|
|
|
|
}
|
|
|
|
++reqLength;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
pSrcLimit = pSrc+srcLength;
|
|
|
|
while(pSrc<pSrcLimit && pDest<pDestLimit) {
|
|
|
|
ch=*pSrc++;
|
|
|
|
if(UTF_IS_LEAD(ch) && pSrc<pSrcLimit && UTF_IS_TRAIL(ch2=*pSrc)) {
|
|
|
|
++pSrc;
|
|
|
|
ch=UTF16_GET_PAIR_VALUE(ch, ch2);
|
|
|
|
}
|
|
|
|
*(pDest++)= ch;
|
|
|
|
}
|
|
|
|
while(pSrc!=pSrcLimit) {
|
|
|
|
ch=*pSrc++;
|
|
|
|
if(UTF_IS_LEAD(ch) && pSrc<pSrcLimit && UTF_IS_TRAIL(ch2=*pSrc)) {
|
|
|
|
++pSrc;
|
|
|
|
}
|
|
|
|
++reqLength;
|
2001-09-18 03:41:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-05 23:13:25 +00:00
|
|
|
reqLength+=(pDest - (uint32_t *)dest);
|
2001-09-18 03:41:09 +00:00
|
|
|
if(pDestLength){
|
|
|
|
*pDestLength = reqLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Terminate the buffer */
|
|
|
|
u_terminateUChar32s(dest,destCapacity,reqLength,pErrorCode);
|
|
|
|
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
U_CAPI UChar* U_EXPORT2
|
|
|
|
u_strFromUTF8(UChar *dest,
|
|
|
|
int32_t destCapacity,
|
|
|
|
int32_t *pDestLength,
|
2001-09-22 03:00:46 +00:00
|
|
|
const char* src,
|
2001-09-18 03:41:09 +00:00
|
|
|
int32_t srcLength,
|
|
|
|
UErrorCode *pErrorCode){
|
|
|
|
|
|
|
|
UChar *pDest = dest;
|
|
|
|
UChar *pDestLimit = dest+destCapacity;
|
|
|
|
UChar32 ch=0;
|
|
|
|
int32_t index = 0;
|
|
|
|
int32_t reqLength = 0;
|
2001-09-22 03:00:46 +00:00
|
|
|
uint8_t* pSrc = (uint8_t*) src;
|
2002-08-03 00:54:39 +00:00
|
|
|
|
2001-09-18 03:41:09 +00:00
|
|
|
/* args check */
|
2001-11-30 05:20:18 +00:00
|
|
|
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)){
|
2001-09-18 03:41:09 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2001-11-30 05:20:18 +00:00
|
|
|
|
2003-07-24 23:23:19 +00:00
|
|
|
if((src==NULL) || (srcLength < -1) || (destCapacity<0) || (!dest && destCapacity > 0)){
|
2001-09-18 03:41:09 +00:00
|
|
|
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(srcLength == -1){
|
|
|
|
srcLength = uprv_strlen((char*)pSrc);
|
|
|
|
}
|
|
|
|
|
2001-11-30 05:20:18 +00:00
|
|
|
while((index < srcLength)&&(pDest<pDestLimit)){
|
|
|
|
ch = pSrc[index++];
|
|
|
|
if(ch <=0x7f){
|
|
|
|
*pDest++=(UChar)ch;
|
|
|
|
}else{
|
2002-09-30 04:00:17 +00:00
|
|
|
ch=utf8_nextCharSafeBody(pSrc, &index, srcLength, ch, -1);
|
|
|
|
if(ch<0){
|
2002-08-03 00:54:39 +00:00
|
|
|
*pErrorCode = U_INVALID_CHAR_FOUND;
|
|
|
|
return NULL;
|
|
|
|
}else if(ch<=0xFFFF){
|
2001-11-30 05:20:18 +00:00
|
|
|
*(pDest++)=(UChar)ch;
|
2002-08-03 00:54:39 +00:00
|
|
|
}else{
|
2001-11-30 05:20:18 +00:00
|
|
|
*(pDest++)=UTF16_LEAD(ch);
|
|
|
|
if(pDest<pDestLimit){
|
|
|
|
*(pDest++)=UTF16_TRAIL(ch);
|
2001-09-18 03:41:09 +00:00
|
|
|
}else{
|
2001-11-30 05:20:18 +00:00
|
|
|
reqLength++;
|
|
|
|
break;
|
2001-09-18 03:41:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* donot fill the dest buffer just count the UChars needed */
|
|
|
|
while(index < srcLength){
|
|
|
|
ch = pSrc[index++];
|
|
|
|
if(ch <= 0x7f){
|
|
|
|
reqLength++;
|
|
|
|
}else{
|
2002-09-30 04:00:17 +00:00
|
|
|
ch=utf8_nextCharSafeBody(pSrc, &index, srcLength, ch, -1);
|
|
|
|
if(ch<0){
|
2002-08-03 00:54:39 +00:00
|
|
|
*pErrorCode = U_INVALID_CHAR_FOUND;
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-09-18 03:41:09 +00:00
|
|
|
reqLength+=UTF_CHAR_LENGTH(ch);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
reqLength+=(pDest - dest);
|
|
|
|
|
|
|
|
if(pDestLength){
|
|
|
|
*pDestLength = reqLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Terminate the buffer */
|
|
|
|
u_terminateUChars(dest,destCapacity,reqLength,pErrorCode);
|
|
|
|
|
|
|
|
return dest;
|
|
|
|
}
|
2001-11-30 22:15:36 +00:00
|
|
|
|
2002-11-30 04:41:53 +00:00
|
|
|
static U_INLINE uint8_t *
|
2001-11-30 22:15:36 +00:00
|
|
|
_appendUTF8(uint8_t *pDest, UChar32 c) {
|
|
|
|
/* c<=0x7f is handled by the caller, here it is 0x80<=c<=0x10ffff */
|
|
|
|
if((c)<=0x7ff) {
|
2001-11-30 05:20:18 +00:00
|
|
|
*pDest++=(uint8_t)((c>>6)|0xc0);
|
|
|
|
*pDest++=(uint8_t)((c&0x3f)|0x80);
|
|
|
|
} else if((uint32_t)(c)<=0xffff) {
|
|
|
|
*pDest++=(uint8_t)((c>>12)|0xe0);
|
|
|
|
*pDest++=(uint8_t)(((c>>6)&0x3f)|0x80);
|
|
|
|
*pDest++=(uint8_t)(((c)&0x3f)|0x80);
|
2001-11-30 22:15:36 +00:00
|
|
|
} else /* if((uint32_t)(c)<=0x10ffff) */ {
|
2001-11-30 05:20:18 +00:00
|
|
|
*pDest++=(uint8_t)(((c)>>18)|0xf0);
|
|
|
|
*pDest++=(uint8_t)((((c)>>12)&0x3f)|0x80);
|
|
|
|
*pDest++=(uint8_t)((((c)>>6)&0x3f)|0x80);
|
|
|
|
*pDest++=(uint8_t)(((c)&0x3f)|0x80);
|
|
|
|
}
|
2001-11-30 22:15:36 +00:00
|
|
|
return pDest;
|
2001-11-30 05:20:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-22 03:00:46 +00:00
|
|
|
U_CAPI char* U_EXPORT2
|
2001-09-22 03:12:14 +00:00
|
|
|
u_strToUTF8(char *dest,
|
2001-09-18 03:41:09 +00:00
|
|
|
int32_t destCapacity,
|
|
|
|
int32_t *pDestLength,
|
|
|
|
const UChar *pSrc,
|
|
|
|
int32_t srcLength,
|
|
|
|
UErrorCode *pErrorCode){
|
|
|
|
|
|
|
|
int32_t reqLength=0;
|
|
|
|
const UChar *pSrcLimit;
|
2001-11-30 05:20:18 +00:00
|
|
|
uint32_t ch=0,ch2=0;
|
|
|
|
uint8_t *pDest = (uint8_t *)dest;
|
|
|
|
uint8_t *pDestLimit = pDest + destCapacity;
|
|
|
|
|
2001-09-18 03:41:09 +00:00
|
|
|
|
|
|
|
/* args check */
|
2001-11-30 05:20:18 +00:00
|
|
|
if(pErrorCode==NULL || U_FAILURE(*pErrorCode)){
|
2001-09-18 03:41:09 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2001-11-30 05:20:18 +00:00
|
|
|
|
2003-07-24 23:23:19 +00:00
|
|
|
if((pSrc==NULL) || (srcLength < -1) || (destCapacity<0) || (!dest && destCapacity > 0)){
|
2001-09-18 03:41:09 +00:00
|
|
|
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-11-30 05:20:18 +00:00
|
|
|
if(srcLength==-1) {
|
|
|
|
while((ch=*pSrc)!=0 && pDest!=pDestLimit) {
|
|
|
|
++pSrc;
|
2001-11-30 22:15:36 +00:00
|
|
|
if(ch <= 0x7f) {
|
|
|
|
*pDest++ = (char)ch;
|
|
|
|
++reqLength;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2001-11-30 05:20:18 +00:00
|
|
|
/*need not check for NUL because NUL fails UTF_IS_TRAIL() anyway*/
|
2002-07-13 00:46:18 +00:00
|
|
|
if(UTF_IS_SURROGATE(ch)) {
|
|
|
|
if(UTF_IS_SURROGATE_FIRST(ch) && UTF_IS_TRAIL(ch2=*pSrc)) {
|
|
|
|
++pSrc;
|
|
|
|
ch=UTF16_GET_PAIR_VALUE(ch, ch2);
|
|
|
|
} else {
|
|
|
|
/* Unicode 3.2 forbids surrogate code points in UTF-8 */
|
|
|
|
*pErrorCode = U_INVALID_CHAR_FOUND;
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-11-30 05:20:18 +00:00
|
|
|
}
|
|
|
|
reqLength += UTF8_CHAR_LENGTH(ch);
|
|
|
|
/* do we have enough room in destination? */
|
|
|
|
if(destCapacity< reqLength){
|
2001-09-18 03:41:09 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-11-30 05:20:18 +00:00
|
|
|
/* convert and append*/
|
2001-11-30 22:15:36 +00:00
|
|
|
pDest=_appendUTF8(pDest, ch);
|
2001-09-18 03:41:09 +00:00
|
|
|
}
|
2001-11-30 05:20:18 +00:00
|
|
|
while((ch=*pSrc++)!=0) {
|
2002-07-13 00:46:18 +00:00
|
|
|
if(ch<=0x7f) {
|
|
|
|
++reqLength;
|
|
|
|
} else if(ch<=0x7ff) {
|
|
|
|
reqLength+=2;
|
|
|
|
} else if(!UTF_IS_SURROGATE(ch)) {
|
|
|
|
reqLength+=3;
|
|
|
|
} else if(UTF_IS_SURROGATE_FIRST(ch) && UTF_IS_TRAIL(ch2=*pSrc)) {
|
2001-11-30 05:20:18 +00:00
|
|
|
++pSrc;
|
|
|
|
reqLength+=4;
|
|
|
|
} else {
|
2002-07-13 00:46:18 +00:00
|
|
|
/* Unicode 3.2 forbids surrogate code points in UTF-8 */
|
|
|
|
*pErrorCode = U_INVALID_CHAR_FOUND;
|
|
|
|
return NULL;
|
2001-11-30 05:20:18 +00:00
|
|
|
}
|
2001-09-18 03:41:09 +00:00
|
|
|
}
|
2001-11-30 05:20:18 +00:00
|
|
|
} else {
|
|
|
|
pSrcLimit = pSrc+srcLength;
|
|
|
|
while(pSrc<pSrcLimit && pDest<pDestLimit) {
|
|
|
|
ch=*pSrc++;
|
2001-11-30 22:15:36 +00:00
|
|
|
if(ch <= 0x7f) {
|
|
|
|
*pDest++ = (char)ch;
|
|
|
|
++reqLength;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2002-07-13 00:46:18 +00:00
|
|
|
if(UTF_IS_SURROGATE(ch)) {
|
|
|
|
if(UTF_IS_SURROGATE_FIRST(ch) && pSrc<pSrcLimit && UTF_IS_TRAIL(ch2=*pSrc)) {
|
|
|
|
++pSrc;
|
|
|
|
ch=UTF16_GET_PAIR_VALUE(ch, ch2);
|
|
|
|
} else {
|
|
|
|
/* Unicode 3.2 forbids surrogate code points in UTF-8 */
|
|
|
|
*pErrorCode = U_INVALID_CHAR_FOUND;
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-11-30 05:20:18 +00:00
|
|
|
}
|
|
|
|
reqLength += UTF8_CHAR_LENGTH(ch);
|
|
|
|
/* do we have enough room in destination? */
|
|
|
|
if(destCapacity< reqLength){
|
2001-09-18 03:41:09 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-11-30 05:20:18 +00:00
|
|
|
/* convert and append*/
|
2001-11-30 22:15:36 +00:00
|
|
|
pDest=_appendUTF8(pDest, ch);
|
2001-09-18 03:41:09 +00:00
|
|
|
}
|
2001-11-30 05:20:18 +00:00
|
|
|
while(pSrc<pSrcLimit) {
|
|
|
|
ch=*pSrc++;
|
2002-07-13 00:46:18 +00:00
|
|
|
if(ch<=0x7f) {
|
|
|
|
++reqLength;
|
|
|
|
} else if(ch<=0x7ff) {
|
|
|
|
reqLength+=2;
|
|
|
|
} else if(!UTF_IS_SURROGATE(ch)) {
|
|
|
|
reqLength+=3;
|
|
|
|
} else if(UTF_IS_SURROGATE_FIRST(ch) && pSrc<pSrcLimit && UTF_IS_TRAIL(ch2=*pSrc)) {
|
2001-11-30 05:20:18 +00:00
|
|
|
++pSrc;
|
|
|
|
reqLength+=4;
|
|
|
|
} else {
|
2002-07-13 00:46:18 +00:00
|
|
|
/* Unicode 3.2 forbids surrogate code points in UTF-8 */
|
|
|
|
*pErrorCode = U_INVALID_CHAR_FOUND;
|
|
|
|
return NULL;
|
2001-11-30 05:20:18 +00:00
|
|
|
}
|
2001-09-18 03:41:09 +00:00
|
|
|
}
|
|
|
|
}
|
2001-11-30 05:20:18 +00:00
|
|
|
|
2001-09-18 03:41:09 +00:00
|
|
|
if(pDestLength){
|
|
|
|
*pDestLength = reqLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Terminate the buffer */
|
|
|
|
u_terminateChars((char*)dest,destCapacity,reqLength,pErrorCode);
|
|
|
|
|
2001-09-22 03:00:46 +00:00
|
|
|
return (char*)dest;
|
2001-09-18 03:41:09 +00:00
|
|
|
}
|