/*
*******************************************************************************
*
-* Copyright (C) 1998-2000, International Business Machines
+* Copyright (C) 1998-2006, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
#include "cmemory.h"
#include "cstring.h"
#include "unicode/ustring.h"
+#include "unicode/putil.h"
/* Protos */
static void ustr_resize(struct UString *s, int32_t len, UErrorCode *status);
if(U_FAILURE(*status))
return;
}
-
+ if(src->fChars == NULL || dst->fChars == NULL){
+ return;
+ }
uprv_memcpy(dst->fChars, src->fChars, sizeof(UChar) * src->fLength);
dst->fLength = src->fLength;
dst->fChars[dst->fLength] = 0x0000;
dst->fLength += 1;
dst->fChars[dst->fLength] = 0x0000;
}
-
+void
+ustr_u32cat(struct UString *dst, UChar32 c, UErrorCode *status){
+ if(c > 0x10FFFF){
+ *status = U_ILLEGAL_CHAR_FOUND;
+ return;
+ }
+ if(c >0xFFFF){
+ ustr_ucat(dst, U16_LEAD(c), status);
+ ustr_ucat(dst, U16_TRAIL(c), status);
+ }else{
+ ustr_ucat(dst, (UChar) c, status);
+ }
+}
void
ustr_uscat(struct UString *dst,
const UChar* src,int len,
s->fChars = (UChar*) uprv_realloc(s->fChars, sizeof(UChar) * (len + 1));
if(s->fChars == 0) {
*status = U_MEMORY_ALLOCATION_ERROR;
- s->fChars = 0;
s->fLength = s->fCapacity = 0;
return;
}