1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 /* 4 ******************************************************************************* 5 * 6 * Copyright (C) 1998-2012, International Business Machines 7 * Corporation and others. All Rights Reserved. 8 * 9 ******************************************************************************* 10 * 11 * File ustr.h 12 * 13 * Modification History: 14 * 15 * Date Name Description 16 * 05/28/99 stephen Creation. 17 ******************************************************************************* 18 */ 19 20 #ifndef USTR_H 21 #define USTR_H 1 22 23 #include "unicode/utypes.h" 24 25 #define U_APPEND_CHAR32(c,target,len) UPRV_BLOCK_MACRO_BEGIN { \ 26 if (c <= 0xffff) \ 27 { \ 28 *(target)++ = (UChar) c; \ 29 len=1; \ 30 } \ 31 else \ 32 { \ 33 target[0] = U16_LEAD(c); \ 34 target[1] = U16_TRAIL(c); \ 35 len=2; \ 36 target +=2; \ 37 } \ 38 } UPRV_BLOCK_MACRO_END 39 40 #define U_APPEND_CHAR32_ONLY(c,target) UPRV_BLOCK_MACRO_BEGIN { \ 41 if (c <= 0xffff) \ 42 { \ 43 *(target)++ = (UChar) c; \ 44 } \ 45 else \ 46 { \ 47 target[0] = U16_LEAD(c); \ 48 target[1] = U16_TRAIL(c); \ 49 target +=2; \ 50 } \ 51 } UPRV_BLOCK_MACRO_END 52 53 /* A C representation of a string "object" (to avoid realloc all the time) */ 54 struct UString { 55 UChar *fChars; 56 int32_t fLength; 57 int32_t fCapacity; 58 }; 59 60 U_CFUNC void ustr_init(struct UString *s); 61 62 U_CFUNC void 63 ustr_initChars(struct UString *s, const char* source, int32_t length, UErrorCode *status); 64 65 U_CFUNC void ustr_deinit(struct UString *s); 66 67 U_CFUNC void ustr_setlen(struct UString *s, int32_t len, UErrorCode *status); 68 69 U_CFUNC void ustr_cpy(struct UString *dst, const struct UString *src, 70 UErrorCode *status); 71 72 U_CFUNC void ustr_cat(struct UString *dst, const struct UString *src, 73 UErrorCode *status); 74 75 U_CFUNC void ustr_ncat(struct UString *dst, const struct UString *src, 76 int32_t n, UErrorCode *status); 77 78 U_CFUNC void ustr_ucat(struct UString *dst, UChar c, UErrorCode *status); 79 U_CFUNC void ustr_u32cat(struct UString *dst, UChar32 c, UErrorCode *status); 80 U_CFUNC void ustr_uscat(struct UString *dst, const UChar* src,int len,UErrorCode *status); 81 #endif 82