1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others. 2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html 3*0e209d39SAndroid Build Coastguard Worker /* 4*0e209d39SAndroid Build Coastguard Worker ********************************************************************** 5*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 1998-2014, International Business Machines 6*0e209d39SAndroid Build Coastguard Worker * Corporation and others. All Rights Reserved. 7*0e209d39SAndroid Build Coastguard Worker ********************************************************************** 8*0e209d39SAndroid Build Coastguard Worker * 9*0e209d39SAndroid Build Coastguard Worker * File ustring.h 10*0e209d39SAndroid Build Coastguard Worker * 11*0e209d39SAndroid Build Coastguard Worker * Modification History: 12*0e209d39SAndroid Build Coastguard Worker * 13*0e209d39SAndroid Build Coastguard Worker * Date Name Description 14*0e209d39SAndroid Build Coastguard Worker * 12/07/98 bertrand Creation. 15*0e209d39SAndroid Build Coastguard Worker ****************************************************************************** 16*0e209d39SAndroid Build Coastguard Worker */ 17*0e209d39SAndroid Build Coastguard Worker 18*0e209d39SAndroid Build Coastguard Worker #ifndef USTRING_H 19*0e209d39SAndroid Build Coastguard Worker #define USTRING_H 20*0e209d39SAndroid Build Coastguard Worker 21*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 22*0e209d39SAndroid Build Coastguard Worker #include "unicode/putil.h" 23*0e209d39SAndroid Build Coastguard Worker 24*0e209d39SAndroid Build Coastguard Worker /** 25*0e209d39SAndroid Build Coastguard Worker * \def UBRK_TYPEDEF_UBREAK_ITERATOR 26*0e209d39SAndroid Build Coastguard Worker * \xrefitem internal "Internal" "Internal List" Do not use. This API is for internal use only. 27*0e209d39SAndroid Build Coastguard Worker */ 28*0e209d39SAndroid Build Coastguard Worker 29*0e209d39SAndroid Build Coastguard Worker #ifndef UBRK_TYPEDEF_UBREAK_ITERATOR 30*0e209d39SAndroid Build Coastguard Worker # define UBRK_TYPEDEF_UBREAK_ITERATOR 31*0e209d39SAndroid Build Coastguard Worker /** Simple declaration for u_strToTitle() to avoid including unicode/ubrk.h. \xrefitem stable "Stable" "Stable List" ICU 2.1*/ 32*0e209d39SAndroid Build Coastguard Worker typedef struct UBreakIterator UBreakIterator; 33*0e209d39SAndroid Build Coastguard Worker #endif 34*0e209d39SAndroid Build Coastguard Worker 35*0e209d39SAndroid Build Coastguard Worker /** 36*0e209d39SAndroid Build Coastguard Worker * @addtogroup icu4c ICU4C 37*0e209d39SAndroid Build Coastguard Worker * @{ 38*0e209d39SAndroid Build Coastguard Worker * \file 39*0e209d39SAndroid Build Coastguard Worker * \brief C API: Unicode string handling functions 40*0e209d39SAndroid Build Coastguard Worker * 41*0e209d39SAndroid Build Coastguard Worker * These C API functions provide general Unicode string handling. 42*0e209d39SAndroid Build Coastguard Worker * 43*0e209d39SAndroid Build Coastguard Worker * Some functions are equivalent in name, signature, and behavior to the ANSI C <string.h> 44*0e209d39SAndroid Build Coastguard Worker * functions. (For example, they do not check for bad arguments like NULL string pointers.) 45*0e209d39SAndroid Build Coastguard Worker * In some cases, only the thread-safe variant of such a function is implemented here 46*0e209d39SAndroid Build Coastguard Worker * (see u_strtok_r()). 47*0e209d39SAndroid Build Coastguard Worker * 48*0e209d39SAndroid Build Coastguard Worker * Other functions provide more Unicode-specific functionality like locale-specific 49*0e209d39SAndroid Build Coastguard Worker * upper/lower-casing and string comparison in code point order. 50*0e209d39SAndroid Build Coastguard Worker * 51*0e209d39SAndroid Build Coastguard Worker * ICU uses 16-bit Unicode (UTF-16) in the form of arrays of UChar code units. 52*0e209d39SAndroid Build Coastguard Worker * UTF-16 encodes each Unicode code point with either one or two UChar code units. 53*0e209d39SAndroid Build Coastguard Worker * (This is the default form of Unicode, and a forward-compatible extension of the original, 54*0e209d39SAndroid Build Coastguard Worker * fixed-width form that was known as UCS-2. UTF-16 superseded UCS-2 with Unicode 2.0 55*0e209d39SAndroid Build Coastguard Worker * in 1996.) 56*0e209d39SAndroid Build Coastguard Worker * 57*0e209d39SAndroid Build Coastguard Worker * Some APIs accept a 32-bit UChar32 value for a single code point. 58*0e209d39SAndroid Build Coastguard Worker * 59*0e209d39SAndroid Build Coastguard Worker * ICU also handles 16-bit Unicode text with unpaired surrogates. 60*0e209d39SAndroid Build Coastguard Worker * Such text is not well-formed UTF-16. 61*0e209d39SAndroid Build Coastguard Worker * Code-point-related functions treat unpaired surrogates as surrogate code points, 62*0e209d39SAndroid Build Coastguard Worker * i.e., as separate units. 63*0e209d39SAndroid Build Coastguard Worker * 64*0e209d39SAndroid Build Coastguard Worker * Although UTF-16 is a variable-width encoding form (like some legacy multi-byte encodings), 65*0e209d39SAndroid Build Coastguard Worker * it is much more efficient even for random access because the code unit values 66*0e209d39SAndroid Build Coastguard Worker * for single-unit characters vs. lead units vs. trail units are completely disjoint. 67*0e209d39SAndroid Build Coastguard Worker * This means that it is easy to determine character (code point) boundaries from 68*0e209d39SAndroid Build Coastguard Worker * random offsets in the string. 69*0e209d39SAndroid Build Coastguard Worker * 70*0e209d39SAndroid Build Coastguard Worker * Unicode (UTF-16) string processing is optimized for the single-unit case. 71*0e209d39SAndroid Build Coastguard Worker * Although it is important to support supplementary characters 72*0e209d39SAndroid Build Coastguard Worker * (which use pairs of lead/trail code units called "surrogates"), 73*0e209d39SAndroid Build Coastguard Worker * their occurrence is rare. Almost all characters in modern use require only 74*0e209d39SAndroid Build Coastguard Worker * a single UChar code unit (i.e., their code point values are <=0xffff). 75*0e209d39SAndroid Build Coastguard Worker * 76*0e209d39SAndroid Build Coastguard Worker * For more details see the User Guide Strings chapter (https://unicode-org.github.io/icu/userguide/strings/). 77*0e209d39SAndroid Build Coastguard Worker * For a discussion of the handling of unpaired surrogates see also 78*0e209d39SAndroid Build Coastguard Worker * Jitterbug 2145 and its icu mailing list proposal on 2002-sep-18. 79*0e209d39SAndroid Build Coastguard Worker */ 80*0e209d39SAndroid Build Coastguard Worker 81*0e209d39SAndroid Build Coastguard Worker /** 82*0e209d39SAndroid Build Coastguard Worker * Determine the length of an array of UChar. 83*0e209d39SAndroid Build Coastguard Worker * 84*0e209d39SAndroid Build Coastguard Worker * @param s The array of UChars, NULL (U+0000) terminated. 85*0e209d39SAndroid Build Coastguard Worker * @return The number of UChars in <code>chars</code>, minus the terminator. 86*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 87*0e209d39SAndroid Build Coastguard Worker */ 88*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 89*0e209d39SAndroid Build Coastguard Worker u_strlen(const UChar *s) __INTRODUCED_IN(31); 90*0e209d39SAndroid Build Coastguard Worker 91*0e209d39SAndroid Build Coastguard Worker 92*0e209d39SAndroid Build Coastguard Worker 93*0e209d39SAndroid Build Coastguard Worker /** 94*0e209d39SAndroid Build Coastguard Worker * Count Unicode code points in the length UChar code units of the string. 95*0e209d39SAndroid Build Coastguard Worker * A code point may occupy either one or two UChar code units. 96*0e209d39SAndroid Build Coastguard Worker * Counting code points involves reading all code units. 97*0e209d39SAndroid Build Coastguard Worker * 98*0e209d39SAndroid Build Coastguard Worker * This functions is basically the inverse of the U16_FWD_N() macro (see utf.h). 99*0e209d39SAndroid Build Coastguard Worker * 100*0e209d39SAndroid Build Coastguard Worker * @param s The input string. 101*0e209d39SAndroid Build Coastguard Worker * @param length The number of UChar code units to be checked, or -1 to count all 102*0e209d39SAndroid Build Coastguard Worker * code points before the first NUL (U+0000). 103*0e209d39SAndroid Build Coastguard Worker * @return The number of code points in the specified code units. 104*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 105*0e209d39SAndroid Build Coastguard Worker */ 106*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 107*0e209d39SAndroid Build Coastguard Worker u_countChar32(const UChar *s, int32_t length) __INTRODUCED_IN(31); 108*0e209d39SAndroid Build Coastguard Worker 109*0e209d39SAndroid Build Coastguard Worker 110*0e209d39SAndroid Build Coastguard Worker 111*0e209d39SAndroid Build Coastguard Worker /** 112*0e209d39SAndroid Build Coastguard Worker * Check if the string contains more Unicode code points than a certain number. 113*0e209d39SAndroid Build Coastguard Worker * This is more efficient than counting all code points in the entire string 114*0e209d39SAndroid Build Coastguard Worker * and comparing that number with a threshold. 115*0e209d39SAndroid Build Coastguard Worker * This function may not need to scan the string at all if the length is known 116*0e209d39SAndroid Build Coastguard Worker * (not -1 for NUL-termination) and falls within a certain range, and 117*0e209d39SAndroid Build Coastguard Worker * never needs to count more than 'number+1' code points. 118*0e209d39SAndroid Build Coastguard Worker * Logically equivalent to (u_countChar32(s, length)>number). 119*0e209d39SAndroid Build Coastguard Worker * A Unicode code point may occupy either one or two UChar code units. 120*0e209d39SAndroid Build Coastguard Worker * 121*0e209d39SAndroid Build Coastguard Worker * @param s The input string. 122*0e209d39SAndroid Build Coastguard Worker * @param length The length of the string, or -1 if it is NUL-terminated. 123*0e209d39SAndroid Build Coastguard Worker * @param number The number of code points in the string is compared against 124*0e209d39SAndroid Build Coastguard Worker * the 'number' parameter. 125*0e209d39SAndroid Build Coastguard Worker * @return Boolean value for whether the string contains more Unicode code points 126*0e209d39SAndroid Build Coastguard Worker * than 'number'. Same as (u_countChar32(s, length)>number). 127*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.4 128*0e209d39SAndroid Build Coastguard Worker */ 129*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 130*0e209d39SAndroid Build Coastguard Worker u_strHasMoreChar32Than(const UChar *s, int32_t length, int32_t number) __INTRODUCED_IN(31); 131*0e209d39SAndroid Build Coastguard Worker 132*0e209d39SAndroid Build Coastguard Worker 133*0e209d39SAndroid Build Coastguard Worker 134*0e209d39SAndroid Build Coastguard Worker /** 135*0e209d39SAndroid Build Coastguard Worker * Concatenate two ustrings. Appends a copy of <code>src</code>, 136*0e209d39SAndroid Build Coastguard Worker * including the null terminator, to <code>dst</code>. The initial copied 137*0e209d39SAndroid Build Coastguard Worker * character from <code>src</code> overwrites the null terminator in <code>dst</code>. 138*0e209d39SAndroid Build Coastguard Worker * 139*0e209d39SAndroid Build Coastguard Worker * @param dst The destination string. 140*0e209d39SAndroid Build Coastguard Worker * @param src The source string. 141*0e209d39SAndroid Build Coastguard Worker * @return A pointer to <code>dst</code>. 142*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 143*0e209d39SAndroid Build Coastguard Worker */ 144*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar* U_EXPORT2 145*0e209d39SAndroid Build Coastguard Worker u_strcat(UChar *dst, 146*0e209d39SAndroid Build Coastguard Worker const UChar *src) __INTRODUCED_IN(31); 147*0e209d39SAndroid Build Coastguard Worker 148*0e209d39SAndroid Build Coastguard Worker 149*0e209d39SAndroid Build Coastguard Worker 150*0e209d39SAndroid Build Coastguard Worker /** 151*0e209d39SAndroid Build Coastguard Worker * Concatenate two ustrings. 152*0e209d39SAndroid Build Coastguard Worker * Appends at most <code>n</code> characters from <code>src</code> to <code>dst</code>. 153*0e209d39SAndroid Build Coastguard Worker * Adds a terminating NUL. 154*0e209d39SAndroid Build Coastguard Worker * If src is too long, then only <code>n-1</code> characters will be copied 155*0e209d39SAndroid Build Coastguard Worker * before the terminating NUL. 156*0e209d39SAndroid Build Coastguard Worker * If <code>n<=0</code> then dst is not modified. 157*0e209d39SAndroid Build Coastguard Worker * 158*0e209d39SAndroid Build Coastguard Worker * @param dst The destination string. 159*0e209d39SAndroid Build Coastguard Worker * @param src The source string (can be NULL/invalid if n<=0). 160*0e209d39SAndroid Build Coastguard Worker * @param n The maximum number of characters to append; no-op if <=0. 161*0e209d39SAndroid Build Coastguard Worker * @return A pointer to <code>dst</code>. 162*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 163*0e209d39SAndroid Build Coastguard Worker */ 164*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar* U_EXPORT2 165*0e209d39SAndroid Build Coastguard Worker u_strncat(UChar *dst, 166*0e209d39SAndroid Build Coastguard Worker const UChar *src, 167*0e209d39SAndroid Build Coastguard Worker int32_t n) __INTRODUCED_IN(31); 168*0e209d39SAndroid Build Coastguard Worker 169*0e209d39SAndroid Build Coastguard Worker 170*0e209d39SAndroid Build Coastguard Worker 171*0e209d39SAndroid Build Coastguard Worker /** 172*0e209d39SAndroid Build Coastguard Worker * Find the first occurrence of a substring in a string. 173*0e209d39SAndroid Build Coastguard Worker * The substring is found at code point boundaries. 174*0e209d39SAndroid Build Coastguard Worker * That means that if the substring begins with 175*0e209d39SAndroid Build Coastguard Worker * a trail surrogate or ends with a lead surrogate, 176*0e209d39SAndroid Build Coastguard Worker * then it is found only if these surrogates stand alone in the text. 177*0e209d39SAndroid Build Coastguard Worker * Otherwise, the substring edge units would be matched against 178*0e209d39SAndroid Build Coastguard Worker * halves of surrogate pairs. 179*0e209d39SAndroid Build Coastguard Worker * 180*0e209d39SAndroid Build Coastguard Worker * @param s The string to search (NUL-terminated). 181*0e209d39SAndroid Build Coastguard Worker * @param substring The substring to find (NUL-terminated). 182*0e209d39SAndroid Build Coastguard Worker * @return A pointer to the first occurrence of <code>substring</code> in <code>s</code>, 183*0e209d39SAndroid Build Coastguard Worker * or <code>s</code> itself if the <code>substring</code> is empty, 184*0e209d39SAndroid Build Coastguard Worker * or <code>NULL</code> if <code>substring</code> is not in <code>s</code>. 185*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 186*0e209d39SAndroid Build Coastguard Worker * 187*0e209d39SAndroid Build Coastguard Worker * @see u_strrstr 188*0e209d39SAndroid Build Coastguard Worker * @see u_strFindFirst 189*0e209d39SAndroid Build Coastguard Worker * @see u_strFindLast 190*0e209d39SAndroid Build Coastguard Worker */ 191*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar * U_EXPORT2 192*0e209d39SAndroid Build Coastguard Worker u_strstr(const UChar *s, const UChar *substring) __INTRODUCED_IN(31); 193*0e209d39SAndroid Build Coastguard Worker 194*0e209d39SAndroid Build Coastguard Worker 195*0e209d39SAndroid Build Coastguard Worker 196*0e209d39SAndroid Build Coastguard Worker /** 197*0e209d39SAndroid Build Coastguard Worker * Find the first occurrence of a substring in a string. 198*0e209d39SAndroid Build Coastguard Worker * The substring is found at code point boundaries. 199*0e209d39SAndroid Build Coastguard Worker * That means that if the substring begins with 200*0e209d39SAndroid Build Coastguard Worker * a trail surrogate or ends with a lead surrogate, 201*0e209d39SAndroid Build Coastguard Worker * then it is found only if these surrogates stand alone in the text. 202*0e209d39SAndroid Build Coastguard Worker * Otherwise, the substring edge units would be matched against 203*0e209d39SAndroid Build Coastguard Worker * halves of surrogate pairs. 204*0e209d39SAndroid Build Coastguard Worker * 205*0e209d39SAndroid Build Coastguard Worker * @param s The string to search. 206*0e209d39SAndroid Build Coastguard Worker * @param length The length of s (number of UChars), or -1 if it is NUL-terminated. 207*0e209d39SAndroid Build Coastguard Worker * @param substring The substring to find (NUL-terminated). 208*0e209d39SAndroid Build Coastguard Worker * @param subLength The length of substring (number of UChars), or -1 if it is NUL-terminated. 209*0e209d39SAndroid Build Coastguard Worker * @return A pointer to the first occurrence of <code>substring</code> in <code>s</code>, 210*0e209d39SAndroid Build Coastguard Worker * or <code>s</code> itself if the <code>substring</code> is empty, 211*0e209d39SAndroid Build Coastguard Worker * or <code>NULL</code> if <code>substring</code> is not in <code>s</code>. 212*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.4 213*0e209d39SAndroid Build Coastguard Worker * 214*0e209d39SAndroid Build Coastguard Worker * @see u_strstr 215*0e209d39SAndroid Build Coastguard Worker * @see u_strFindLast 216*0e209d39SAndroid Build Coastguard Worker */ 217*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar * U_EXPORT2 218*0e209d39SAndroid Build Coastguard Worker u_strFindFirst(const UChar *s, int32_t length, const UChar *substring, int32_t subLength) __INTRODUCED_IN(31); 219*0e209d39SAndroid Build Coastguard Worker 220*0e209d39SAndroid Build Coastguard Worker 221*0e209d39SAndroid Build Coastguard Worker 222*0e209d39SAndroid Build Coastguard Worker /** 223*0e209d39SAndroid Build Coastguard Worker * Find the first occurrence of a BMP code point in a string. 224*0e209d39SAndroid Build Coastguard Worker * A surrogate code point is found only if its match in the text is not 225*0e209d39SAndroid Build Coastguard Worker * part of a surrogate pair. 226*0e209d39SAndroid Build Coastguard Worker * A NUL character is found at the string terminator. 227*0e209d39SAndroid Build Coastguard Worker * 228*0e209d39SAndroid Build Coastguard Worker * @param s The string to search (NUL-terminated). 229*0e209d39SAndroid Build Coastguard Worker * @param c The BMP code point to find. 230*0e209d39SAndroid Build Coastguard Worker * @return A pointer to the first occurrence of <code>c</code> in <code>s</code> 231*0e209d39SAndroid Build Coastguard Worker * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. 232*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 233*0e209d39SAndroid Build Coastguard Worker * 234*0e209d39SAndroid Build Coastguard Worker * @see u_strchr32 235*0e209d39SAndroid Build Coastguard Worker * @see u_memchr 236*0e209d39SAndroid Build Coastguard Worker * @see u_strstr 237*0e209d39SAndroid Build Coastguard Worker * @see u_strFindFirst 238*0e209d39SAndroid Build Coastguard Worker */ 239*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar * U_EXPORT2 240*0e209d39SAndroid Build Coastguard Worker u_strchr(const UChar *s, UChar c) __INTRODUCED_IN(31); 241*0e209d39SAndroid Build Coastguard Worker 242*0e209d39SAndroid Build Coastguard Worker 243*0e209d39SAndroid Build Coastguard Worker 244*0e209d39SAndroid Build Coastguard Worker /** 245*0e209d39SAndroid Build Coastguard Worker * Find the first occurrence of a code point in a string. 246*0e209d39SAndroid Build Coastguard Worker * A surrogate code point is found only if its match in the text is not 247*0e209d39SAndroid Build Coastguard Worker * part of a surrogate pair. 248*0e209d39SAndroid Build Coastguard Worker * A NUL character is found at the string terminator. 249*0e209d39SAndroid Build Coastguard Worker * 250*0e209d39SAndroid Build Coastguard Worker * @param s The string to search (NUL-terminated). 251*0e209d39SAndroid Build Coastguard Worker * @param c The code point to find. 252*0e209d39SAndroid Build Coastguard Worker * @return A pointer to the first occurrence of <code>c</code> in <code>s</code> 253*0e209d39SAndroid Build Coastguard Worker * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. 254*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 255*0e209d39SAndroid Build Coastguard Worker * 256*0e209d39SAndroid Build Coastguard Worker * @see u_strchr 257*0e209d39SAndroid Build Coastguard Worker * @see u_memchr32 258*0e209d39SAndroid Build Coastguard Worker * @see u_strstr 259*0e209d39SAndroid Build Coastguard Worker * @see u_strFindFirst 260*0e209d39SAndroid Build Coastguard Worker */ 261*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar * U_EXPORT2 262*0e209d39SAndroid Build Coastguard Worker u_strchr32(const UChar *s, UChar32 c) __INTRODUCED_IN(31); 263*0e209d39SAndroid Build Coastguard Worker 264*0e209d39SAndroid Build Coastguard Worker 265*0e209d39SAndroid Build Coastguard Worker 266*0e209d39SAndroid Build Coastguard Worker /** 267*0e209d39SAndroid Build Coastguard Worker * Find the last occurrence of a substring in a string. 268*0e209d39SAndroid Build Coastguard Worker * The substring is found at code point boundaries. 269*0e209d39SAndroid Build Coastguard Worker * That means that if the substring begins with 270*0e209d39SAndroid Build Coastguard Worker * a trail surrogate or ends with a lead surrogate, 271*0e209d39SAndroid Build Coastguard Worker * then it is found only if these surrogates stand alone in the text. 272*0e209d39SAndroid Build Coastguard Worker * Otherwise, the substring edge units would be matched against 273*0e209d39SAndroid Build Coastguard Worker * halves of surrogate pairs. 274*0e209d39SAndroid Build Coastguard Worker * 275*0e209d39SAndroid Build Coastguard Worker * @param s The string to search (NUL-terminated). 276*0e209d39SAndroid Build Coastguard Worker * @param substring The substring to find (NUL-terminated). 277*0e209d39SAndroid Build Coastguard Worker * @return A pointer to the last occurrence of <code>substring</code> in <code>s</code>, 278*0e209d39SAndroid Build Coastguard Worker * or <code>s</code> itself if the <code>substring</code> is empty, 279*0e209d39SAndroid Build Coastguard Worker * or <code>NULL</code> if <code>substring</code> is not in <code>s</code>. 280*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.4 281*0e209d39SAndroid Build Coastguard Worker * 282*0e209d39SAndroid Build Coastguard Worker * @see u_strstr 283*0e209d39SAndroid Build Coastguard Worker * @see u_strFindFirst 284*0e209d39SAndroid Build Coastguard Worker * @see u_strFindLast 285*0e209d39SAndroid Build Coastguard Worker */ 286*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar * U_EXPORT2 287*0e209d39SAndroid Build Coastguard Worker u_strrstr(const UChar *s, const UChar *substring) __INTRODUCED_IN(31); 288*0e209d39SAndroid Build Coastguard Worker 289*0e209d39SAndroid Build Coastguard Worker 290*0e209d39SAndroid Build Coastguard Worker 291*0e209d39SAndroid Build Coastguard Worker /** 292*0e209d39SAndroid Build Coastguard Worker * Find the last occurrence of a substring in a string. 293*0e209d39SAndroid Build Coastguard Worker * The substring is found at code point boundaries. 294*0e209d39SAndroid Build Coastguard Worker * That means that if the substring begins with 295*0e209d39SAndroid Build Coastguard Worker * a trail surrogate or ends with a lead surrogate, 296*0e209d39SAndroid Build Coastguard Worker * then it is found only if these surrogates stand alone in the text. 297*0e209d39SAndroid Build Coastguard Worker * Otherwise, the substring edge units would be matched against 298*0e209d39SAndroid Build Coastguard Worker * halves of surrogate pairs. 299*0e209d39SAndroid Build Coastguard Worker * 300*0e209d39SAndroid Build Coastguard Worker * @param s The string to search. 301*0e209d39SAndroid Build Coastguard Worker * @param length The length of s (number of UChars), or -1 if it is NUL-terminated. 302*0e209d39SAndroid Build Coastguard Worker * @param substring The substring to find (NUL-terminated). 303*0e209d39SAndroid Build Coastguard Worker * @param subLength The length of substring (number of UChars), or -1 if it is NUL-terminated. 304*0e209d39SAndroid Build Coastguard Worker * @return A pointer to the last occurrence of <code>substring</code> in <code>s</code>, 305*0e209d39SAndroid Build Coastguard Worker * or <code>s</code> itself if the <code>substring</code> is empty, 306*0e209d39SAndroid Build Coastguard Worker * or <code>NULL</code> if <code>substring</code> is not in <code>s</code>. 307*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.4 308*0e209d39SAndroid Build Coastguard Worker * 309*0e209d39SAndroid Build Coastguard Worker * @see u_strstr 310*0e209d39SAndroid Build Coastguard Worker * @see u_strFindLast 311*0e209d39SAndroid Build Coastguard Worker */ 312*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar * U_EXPORT2 313*0e209d39SAndroid Build Coastguard Worker u_strFindLast(const UChar *s, int32_t length, const UChar *substring, int32_t subLength) __INTRODUCED_IN(31); 314*0e209d39SAndroid Build Coastguard Worker 315*0e209d39SAndroid Build Coastguard Worker 316*0e209d39SAndroid Build Coastguard Worker 317*0e209d39SAndroid Build Coastguard Worker /** 318*0e209d39SAndroid Build Coastguard Worker * Find the last occurrence of a BMP code point in a string. 319*0e209d39SAndroid Build Coastguard Worker * A surrogate code point is found only if its match in the text is not 320*0e209d39SAndroid Build Coastguard Worker * part of a surrogate pair. 321*0e209d39SAndroid Build Coastguard Worker * A NUL character is found at the string terminator. 322*0e209d39SAndroid Build Coastguard Worker * 323*0e209d39SAndroid Build Coastguard Worker * @param s The string to search (NUL-terminated). 324*0e209d39SAndroid Build Coastguard Worker * @param c The BMP code point to find. 325*0e209d39SAndroid Build Coastguard Worker * @return A pointer to the last occurrence of <code>c</code> in <code>s</code> 326*0e209d39SAndroid Build Coastguard Worker * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. 327*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.4 328*0e209d39SAndroid Build Coastguard Worker * 329*0e209d39SAndroid Build Coastguard Worker * @see u_strrchr32 330*0e209d39SAndroid Build Coastguard Worker * @see u_memrchr 331*0e209d39SAndroid Build Coastguard Worker * @see u_strrstr 332*0e209d39SAndroid Build Coastguard Worker * @see u_strFindLast 333*0e209d39SAndroid Build Coastguard Worker */ 334*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar * U_EXPORT2 335*0e209d39SAndroid Build Coastguard Worker u_strrchr(const UChar *s, UChar c) __INTRODUCED_IN(31); 336*0e209d39SAndroid Build Coastguard Worker 337*0e209d39SAndroid Build Coastguard Worker 338*0e209d39SAndroid Build Coastguard Worker 339*0e209d39SAndroid Build Coastguard Worker /** 340*0e209d39SAndroid Build Coastguard Worker * Find the last occurrence of a code point in a string. 341*0e209d39SAndroid Build Coastguard Worker * A surrogate code point is found only if its match in the text is not 342*0e209d39SAndroid Build Coastguard Worker * part of a surrogate pair. 343*0e209d39SAndroid Build Coastguard Worker * A NUL character is found at the string terminator. 344*0e209d39SAndroid Build Coastguard Worker * 345*0e209d39SAndroid Build Coastguard Worker * @param s The string to search (NUL-terminated). 346*0e209d39SAndroid Build Coastguard Worker * @param c The code point to find. 347*0e209d39SAndroid Build Coastguard Worker * @return A pointer to the last occurrence of <code>c</code> in <code>s</code> 348*0e209d39SAndroid Build Coastguard Worker * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. 349*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.4 350*0e209d39SAndroid Build Coastguard Worker * 351*0e209d39SAndroid Build Coastguard Worker * @see u_strrchr 352*0e209d39SAndroid Build Coastguard Worker * @see u_memchr32 353*0e209d39SAndroid Build Coastguard Worker * @see u_strrstr 354*0e209d39SAndroid Build Coastguard Worker * @see u_strFindLast 355*0e209d39SAndroid Build Coastguard Worker */ 356*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar * U_EXPORT2 357*0e209d39SAndroid Build Coastguard Worker u_strrchr32(const UChar *s, UChar32 c) __INTRODUCED_IN(31); 358*0e209d39SAndroid Build Coastguard Worker 359*0e209d39SAndroid Build Coastguard Worker 360*0e209d39SAndroid Build Coastguard Worker 361*0e209d39SAndroid Build Coastguard Worker /** 362*0e209d39SAndroid Build Coastguard Worker * Locates the first occurrence in the string <code>string</code> of any of the characters 363*0e209d39SAndroid Build Coastguard Worker * in the string <code>matchSet</code>. 364*0e209d39SAndroid Build Coastguard Worker * Works just like C's strpbrk but with Unicode. 365*0e209d39SAndroid Build Coastguard Worker * 366*0e209d39SAndroid Build Coastguard Worker * @param string The string in which to search, NUL-terminated. 367*0e209d39SAndroid Build Coastguard Worker * @param matchSet A NUL-terminated string defining a set of code points 368*0e209d39SAndroid Build Coastguard Worker * for which to search in the text string. 369*0e209d39SAndroid Build Coastguard Worker * @return A pointer to the character in <code>string</code> that matches one of the 370*0e209d39SAndroid Build Coastguard Worker * characters in <code>matchSet</code>, or NULL if no such character is found. 371*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 372*0e209d39SAndroid Build Coastguard Worker */ 373*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar * U_EXPORT2 374*0e209d39SAndroid Build Coastguard Worker u_strpbrk(const UChar *string, const UChar *matchSet) __INTRODUCED_IN(31); 375*0e209d39SAndroid Build Coastguard Worker 376*0e209d39SAndroid Build Coastguard Worker 377*0e209d39SAndroid Build Coastguard Worker 378*0e209d39SAndroid Build Coastguard Worker /** 379*0e209d39SAndroid Build Coastguard Worker * Returns the number of consecutive characters in <code>string</code>, 380*0e209d39SAndroid Build Coastguard Worker * beginning with the first, that do not occur somewhere in <code>matchSet</code>. 381*0e209d39SAndroid Build Coastguard Worker * Works just like C's strcspn but with Unicode. 382*0e209d39SAndroid Build Coastguard Worker * 383*0e209d39SAndroid Build Coastguard Worker * @param string The string in which to search, NUL-terminated. 384*0e209d39SAndroid Build Coastguard Worker * @param matchSet A NUL-terminated string defining a set of code points 385*0e209d39SAndroid Build Coastguard Worker * for which to search in the text string. 386*0e209d39SAndroid Build Coastguard Worker * @return The number of initial characters in <code>string</code> that do not 387*0e209d39SAndroid Build Coastguard Worker * occur in <code>matchSet</code>. 388*0e209d39SAndroid Build Coastguard Worker * @see u_strspn 389*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 390*0e209d39SAndroid Build Coastguard Worker */ 391*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 392*0e209d39SAndroid Build Coastguard Worker u_strcspn(const UChar *string, const UChar *matchSet) __INTRODUCED_IN(31); 393*0e209d39SAndroid Build Coastguard Worker 394*0e209d39SAndroid Build Coastguard Worker 395*0e209d39SAndroid Build Coastguard Worker 396*0e209d39SAndroid Build Coastguard Worker /** 397*0e209d39SAndroid Build Coastguard Worker * Returns the number of consecutive characters in <code>string</code>, 398*0e209d39SAndroid Build Coastguard Worker * beginning with the first, that occur somewhere in <code>matchSet</code>. 399*0e209d39SAndroid Build Coastguard Worker * Works just like C's strspn but with Unicode. 400*0e209d39SAndroid Build Coastguard Worker * 401*0e209d39SAndroid Build Coastguard Worker * @param string The string in which to search, NUL-terminated. 402*0e209d39SAndroid Build Coastguard Worker * @param matchSet A NUL-terminated string defining a set of code points 403*0e209d39SAndroid Build Coastguard Worker * for which to search in the text string. 404*0e209d39SAndroid Build Coastguard Worker * @return The number of initial characters in <code>string</code> that do 405*0e209d39SAndroid Build Coastguard Worker * occur in <code>matchSet</code>. 406*0e209d39SAndroid Build Coastguard Worker * @see u_strcspn 407*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 408*0e209d39SAndroid Build Coastguard Worker */ 409*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 410*0e209d39SAndroid Build Coastguard Worker u_strspn(const UChar *string, const UChar *matchSet) __INTRODUCED_IN(31); 411*0e209d39SAndroid Build Coastguard Worker 412*0e209d39SAndroid Build Coastguard Worker 413*0e209d39SAndroid Build Coastguard Worker 414*0e209d39SAndroid Build Coastguard Worker /** 415*0e209d39SAndroid Build Coastguard Worker * The string tokenizer API allows an application to break a string into 416*0e209d39SAndroid Build Coastguard Worker * tokens. Unlike strtok(), the saveState (the current pointer within the 417*0e209d39SAndroid Build Coastguard Worker * original string) is maintained in saveState. In the first call, the 418*0e209d39SAndroid Build Coastguard Worker * argument src is a pointer to the string. In subsequent calls to 419*0e209d39SAndroid Build Coastguard Worker * return successive tokens of that string, src must be specified as 420*0e209d39SAndroid Build Coastguard Worker * NULL. The value saveState is set by this function to maintain the 421*0e209d39SAndroid Build Coastguard Worker * function's position within the string, and on each subsequent call 422*0e209d39SAndroid Build Coastguard Worker * you must give this argument the same variable. This function does 423*0e209d39SAndroid Build Coastguard Worker * handle surrogate pairs. This function is similar to the strtok_r() 424*0e209d39SAndroid Build Coastguard Worker * the POSIX Threads Extension (1003.1c-1995) version. 425*0e209d39SAndroid Build Coastguard Worker * 426*0e209d39SAndroid Build Coastguard Worker * @param src String containing token(s). This string will be modified. 427*0e209d39SAndroid Build Coastguard Worker * After the first call to u_strtok_r(), this argument must 428*0e209d39SAndroid Build Coastguard Worker * be NULL to get to the next token. 429*0e209d39SAndroid Build Coastguard Worker * @param delim Set of delimiter characters (Unicode code points). 430*0e209d39SAndroid Build Coastguard Worker * @param saveState The current pointer within the original string, 431*0e209d39SAndroid Build Coastguard Worker * which is set by this function. The saveState 432*0e209d39SAndroid Build Coastguard Worker * parameter should the address of a local variable of type 433*0e209d39SAndroid Build Coastguard Worker * UChar *. (i.e. defined "UChar *myLocalSaveState" and use 434*0e209d39SAndroid Build Coastguard Worker * &myLocalSaveState for this parameter). 435*0e209d39SAndroid Build Coastguard Worker * @return A pointer to the next token found in src, or NULL 436*0e209d39SAndroid Build Coastguard Worker * when there are no more tokens. 437*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 438*0e209d39SAndroid Build Coastguard Worker */ 439*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar * U_EXPORT2 440*0e209d39SAndroid Build Coastguard Worker u_strtok_r(UChar *src, 441*0e209d39SAndroid Build Coastguard Worker const UChar *delim, 442*0e209d39SAndroid Build Coastguard Worker UChar **saveState) __INTRODUCED_IN(31); 443*0e209d39SAndroid Build Coastguard Worker 444*0e209d39SAndroid Build Coastguard Worker 445*0e209d39SAndroid Build Coastguard Worker 446*0e209d39SAndroid Build Coastguard Worker /** 447*0e209d39SAndroid Build Coastguard Worker * Compare two Unicode strings for bitwise equality (code unit order). 448*0e209d39SAndroid Build Coastguard Worker * 449*0e209d39SAndroid Build Coastguard Worker * @param s1 A string to compare. 450*0e209d39SAndroid Build Coastguard Worker * @param s2 A string to compare. 451*0e209d39SAndroid Build Coastguard Worker * @return 0 if <code>s1</code> and <code>s2</code> are bitwise equal; a negative 452*0e209d39SAndroid Build Coastguard Worker * value if <code>s1</code> is bitwise less than <code>s2,</code>; a positive 453*0e209d39SAndroid Build Coastguard Worker * value if <code>s1</code> is bitwise greater than <code>s2</code>. 454*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 455*0e209d39SAndroid Build Coastguard Worker */ 456*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 457*0e209d39SAndroid Build Coastguard Worker u_strcmp(const UChar *s1, 458*0e209d39SAndroid Build Coastguard Worker const UChar *s2) __INTRODUCED_IN(31); 459*0e209d39SAndroid Build Coastguard Worker 460*0e209d39SAndroid Build Coastguard Worker 461*0e209d39SAndroid Build Coastguard Worker 462*0e209d39SAndroid Build Coastguard Worker /** 463*0e209d39SAndroid Build Coastguard Worker * Compare two Unicode strings in code point order. 464*0e209d39SAndroid Build Coastguard Worker * See u_strCompare for details. 465*0e209d39SAndroid Build Coastguard Worker * 466*0e209d39SAndroid Build Coastguard Worker * @param s1 A string to compare. 467*0e209d39SAndroid Build Coastguard Worker * @param s2 A string to compare. 468*0e209d39SAndroid Build Coastguard Worker * @return a negative/zero/positive integer corresponding to whether 469*0e209d39SAndroid Build Coastguard Worker * the first string is less than/equal to/greater than the second one 470*0e209d39SAndroid Build Coastguard Worker * in code point order 471*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 472*0e209d39SAndroid Build Coastguard Worker */ 473*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 474*0e209d39SAndroid Build Coastguard Worker u_strcmpCodePointOrder(const UChar *s1, const UChar *s2) __INTRODUCED_IN(31); 475*0e209d39SAndroid Build Coastguard Worker 476*0e209d39SAndroid Build Coastguard Worker 477*0e209d39SAndroid Build Coastguard Worker 478*0e209d39SAndroid Build Coastguard Worker /** 479*0e209d39SAndroid Build Coastguard Worker * Compare two Unicode strings (binary order). 480*0e209d39SAndroid Build Coastguard Worker * 481*0e209d39SAndroid Build Coastguard Worker * The comparison can be done in code unit order or in code point order. 482*0e209d39SAndroid Build Coastguard Worker * They differ only in UTF-16 when 483*0e209d39SAndroid Build Coastguard Worker * comparing supplementary code points (U+10000..U+10ffff) 484*0e209d39SAndroid Build Coastguard Worker * to BMP code points near the end of the BMP (i.e., U+e000..U+ffff). 485*0e209d39SAndroid Build Coastguard Worker * In code unit order, high BMP code points sort after supplementary code points 486*0e209d39SAndroid Build Coastguard Worker * because they are stored as pairs of surrogates which are at U+d800..U+dfff. 487*0e209d39SAndroid Build Coastguard Worker * 488*0e209d39SAndroid Build Coastguard Worker * This functions works with strings of different explicitly specified lengths 489*0e209d39SAndroid Build Coastguard Worker * unlike the ANSI C-like u_strcmp() and u_memcmp() etc. 490*0e209d39SAndroid Build Coastguard Worker * NUL-terminated strings are possible with length arguments of -1. 491*0e209d39SAndroid Build Coastguard Worker * 492*0e209d39SAndroid Build Coastguard Worker * @param s1 First source string. 493*0e209d39SAndroid Build Coastguard Worker * @param length1 Length of first source string, or -1 if NUL-terminated. 494*0e209d39SAndroid Build Coastguard Worker * 495*0e209d39SAndroid Build Coastguard Worker * @param s2 Second source string. 496*0e209d39SAndroid Build Coastguard Worker * @param length2 Length of second source string, or -1 if NUL-terminated. 497*0e209d39SAndroid Build Coastguard Worker * 498*0e209d39SAndroid Build Coastguard Worker * @param codePointOrder Choose between code unit order (false) 499*0e209d39SAndroid Build Coastguard Worker * and code point order (true). 500*0e209d39SAndroid Build Coastguard Worker * 501*0e209d39SAndroid Build Coastguard Worker * @return <0 or 0 or >0 as usual for string comparisons 502*0e209d39SAndroid Build Coastguard Worker * 503*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.2 504*0e209d39SAndroid Build Coastguard Worker */ 505*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 506*0e209d39SAndroid Build Coastguard Worker u_strCompare(const UChar *s1, int32_t length1, 507*0e209d39SAndroid Build Coastguard Worker const UChar *s2, int32_t length2, 508*0e209d39SAndroid Build Coastguard Worker UBool codePointOrder) __INTRODUCED_IN(31); 509*0e209d39SAndroid Build Coastguard Worker 510*0e209d39SAndroid Build Coastguard Worker 511*0e209d39SAndroid Build Coastguard Worker 512*0e209d39SAndroid Build Coastguard Worker 513*0e209d39SAndroid Build Coastguard Worker 514*0e209d39SAndroid Build Coastguard Worker /** 515*0e209d39SAndroid Build Coastguard Worker * Compare two strings case-insensitively using full case folding. 516*0e209d39SAndroid Build Coastguard Worker * This is equivalent to 517*0e209d39SAndroid Build Coastguard Worker * u_strCompare(u_strFoldCase(s1, options), 518*0e209d39SAndroid Build Coastguard Worker * u_strFoldCase(s2, options), 519*0e209d39SAndroid Build Coastguard Worker * (options&U_COMPARE_CODE_POINT_ORDER)!=0). 520*0e209d39SAndroid Build Coastguard Worker * 521*0e209d39SAndroid Build Coastguard Worker * The comparison can be done in UTF-16 code unit order or in code point order. 522*0e209d39SAndroid Build Coastguard Worker * They differ only when comparing supplementary code points (U+10000..U+10ffff) 523*0e209d39SAndroid Build Coastguard Worker * to BMP code points near the end of the BMP (i.e., U+e000..U+ffff). 524*0e209d39SAndroid Build Coastguard Worker * In code unit order, high BMP code points sort after supplementary code points 525*0e209d39SAndroid Build Coastguard Worker * because they are stored as pairs of surrogates which are at U+d800..U+dfff. 526*0e209d39SAndroid Build Coastguard Worker * 527*0e209d39SAndroid Build Coastguard Worker * This functions works with strings of different explicitly specified lengths 528*0e209d39SAndroid Build Coastguard Worker * unlike the ANSI C-like u_strcmp() and u_memcmp() etc. 529*0e209d39SAndroid Build Coastguard Worker * NUL-terminated strings are possible with length arguments of -1. 530*0e209d39SAndroid Build Coastguard Worker * 531*0e209d39SAndroid Build Coastguard Worker * @param s1 First source string. 532*0e209d39SAndroid Build Coastguard Worker * @param length1 Length of first source string, or -1 if NUL-terminated. 533*0e209d39SAndroid Build Coastguard Worker * 534*0e209d39SAndroid Build Coastguard Worker * @param s2 Second source string. 535*0e209d39SAndroid Build Coastguard Worker * @param length2 Length of second source string, or -1 if NUL-terminated. 536*0e209d39SAndroid Build Coastguard Worker * 537*0e209d39SAndroid Build Coastguard Worker * @param options A bit set of options: 538*0e209d39SAndroid Build Coastguard Worker * - U_FOLD_CASE_DEFAULT or 0 is used for default options: 539*0e209d39SAndroid Build Coastguard Worker * Comparison in code unit order with default case folding. 540*0e209d39SAndroid Build Coastguard Worker * 541*0e209d39SAndroid Build Coastguard Worker * - U_COMPARE_CODE_POINT_ORDER 542*0e209d39SAndroid Build Coastguard Worker * Set to choose code point order instead of code unit order 543*0e209d39SAndroid Build Coastguard Worker * (see u_strCompare for details). 544*0e209d39SAndroid Build Coastguard Worker * 545*0e209d39SAndroid Build Coastguard Worker * - U_FOLD_CASE_EXCLUDE_SPECIAL_I 546*0e209d39SAndroid Build Coastguard Worker * 547*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 548*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 549*0e209d39SAndroid Build Coastguard Worker * 550*0e209d39SAndroid Build Coastguard Worker * @return <0 or 0 or >0 as usual for string comparisons 551*0e209d39SAndroid Build Coastguard Worker * 552*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.2 553*0e209d39SAndroid Build Coastguard Worker */ 554*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 555*0e209d39SAndroid Build Coastguard Worker u_strCaseCompare(const UChar *s1, int32_t length1, 556*0e209d39SAndroid Build Coastguard Worker const UChar *s2, int32_t length2, 557*0e209d39SAndroid Build Coastguard Worker uint32_t options, 558*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(31); 559*0e209d39SAndroid Build Coastguard Worker 560*0e209d39SAndroid Build Coastguard Worker 561*0e209d39SAndroid Build Coastguard Worker 562*0e209d39SAndroid Build Coastguard Worker /** 563*0e209d39SAndroid Build Coastguard Worker * Compare two ustrings for bitwise equality. 564*0e209d39SAndroid Build Coastguard Worker * Compares at most <code>n</code> characters. 565*0e209d39SAndroid Build Coastguard Worker * 566*0e209d39SAndroid Build Coastguard Worker * @param ucs1 A string to compare (can be NULL/invalid if n<=0). 567*0e209d39SAndroid Build Coastguard Worker * @param ucs2 A string to compare (can be NULL/invalid if n<=0). 568*0e209d39SAndroid Build Coastguard Worker * @param n The maximum number of characters to compare; always returns 0 if n<=0. 569*0e209d39SAndroid Build Coastguard Worker * @return 0 if <code>s1</code> and <code>s2</code> are bitwise equal; a negative 570*0e209d39SAndroid Build Coastguard Worker * value if <code>s1</code> is bitwise less than <code>s2</code>; a positive 571*0e209d39SAndroid Build Coastguard Worker * value if <code>s1</code> is bitwise greater than <code>s2</code>. 572*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 573*0e209d39SAndroid Build Coastguard Worker */ 574*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 575*0e209d39SAndroid Build Coastguard Worker u_strncmp(const UChar *ucs1, 576*0e209d39SAndroid Build Coastguard Worker const UChar *ucs2, 577*0e209d39SAndroid Build Coastguard Worker int32_t n) __INTRODUCED_IN(31); 578*0e209d39SAndroid Build Coastguard Worker 579*0e209d39SAndroid Build Coastguard Worker 580*0e209d39SAndroid Build Coastguard Worker 581*0e209d39SAndroid Build Coastguard Worker /** 582*0e209d39SAndroid Build Coastguard Worker * Compare two Unicode strings in code point order. 583*0e209d39SAndroid Build Coastguard Worker * This is different in UTF-16 from u_strncmp() if supplementary characters are present. 584*0e209d39SAndroid Build Coastguard Worker * For details, see u_strCompare(). 585*0e209d39SAndroid Build Coastguard Worker * 586*0e209d39SAndroid Build Coastguard Worker * @param s1 A string to compare. 587*0e209d39SAndroid Build Coastguard Worker * @param s2 A string to compare. 588*0e209d39SAndroid Build Coastguard Worker * @param n The maximum number of characters to compare. 589*0e209d39SAndroid Build Coastguard Worker * @return a negative/zero/positive integer corresponding to whether 590*0e209d39SAndroid Build Coastguard Worker * the first string is less than/equal to/greater than the second one 591*0e209d39SAndroid Build Coastguard Worker * in code point order 592*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 593*0e209d39SAndroid Build Coastguard Worker */ 594*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 595*0e209d39SAndroid Build Coastguard Worker u_strncmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t n) __INTRODUCED_IN(31); 596*0e209d39SAndroid Build Coastguard Worker 597*0e209d39SAndroid Build Coastguard Worker 598*0e209d39SAndroid Build Coastguard Worker 599*0e209d39SAndroid Build Coastguard Worker /** 600*0e209d39SAndroid Build Coastguard Worker * Compare two strings case-insensitively using full case folding. 601*0e209d39SAndroid Build Coastguard Worker * This is equivalent to u_strcmp(u_strFoldCase(s1, options), u_strFoldCase(s2, options)). 602*0e209d39SAndroid Build Coastguard Worker * 603*0e209d39SAndroid Build Coastguard Worker * @param s1 A string to compare. 604*0e209d39SAndroid Build Coastguard Worker * @param s2 A string to compare. 605*0e209d39SAndroid Build Coastguard Worker * @param options A bit set of options: 606*0e209d39SAndroid Build Coastguard Worker * - U_FOLD_CASE_DEFAULT or 0 is used for default options: 607*0e209d39SAndroid Build Coastguard Worker * Comparison in code unit order with default case folding. 608*0e209d39SAndroid Build Coastguard Worker * 609*0e209d39SAndroid Build Coastguard Worker * - U_COMPARE_CODE_POINT_ORDER 610*0e209d39SAndroid Build Coastguard Worker * Set to choose code point order instead of code unit order 611*0e209d39SAndroid Build Coastguard Worker * (see u_strCompare for details). 612*0e209d39SAndroid Build Coastguard Worker * 613*0e209d39SAndroid Build Coastguard Worker * - U_FOLD_CASE_EXCLUDE_SPECIAL_I 614*0e209d39SAndroid Build Coastguard Worker * 615*0e209d39SAndroid Build Coastguard Worker * @return A negative, zero, or positive integer indicating the comparison result. 616*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 617*0e209d39SAndroid Build Coastguard Worker */ 618*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 619*0e209d39SAndroid Build Coastguard Worker u_strcasecmp(const UChar *s1, const UChar *s2, uint32_t options) __INTRODUCED_IN(31); 620*0e209d39SAndroid Build Coastguard Worker 621*0e209d39SAndroid Build Coastguard Worker 622*0e209d39SAndroid Build Coastguard Worker 623*0e209d39SAndroid Build Coastguard Worker /** 624*0e209d39SAndroid Build Coastguard Worker * Compare two strings case-insensitively using full case folding. 625*0e209d39SAndroid Build Coastguard Worker * This is equivalent to u_strcmp(u_strFoldCase(s1, at most n, options), 626*0e209d39SAndroid Build Coastguard Worker * u_strFoldCase(s2, at most n, options)). 627*0e209d39SAndroid Build Coastguard Worker * 628*0e209d39SAndroid Build Coastguard Worker * @param s1 A string to compare. 629*0e209d39SAndroid Build Coastguard Worker * @param s2 A string to compare. 630*0e209d39SAndroid Build Coastguard Worker * @param n The maximum number of characters each string to case-fold and then compare. 631*0e209d39SAndroid Build Coastguard Worker * @param options A bit set of options: 632*0e209d39SAndroid Build Coastguard Worker * - U_FOLD_CASE_DEFAULT or 0 is used for default options: 633*0e209d39SAndroid Build Coastguard Worker * Comparison in code unit order with default case folding. 634*0e209d39SAndroid Build Coastguard Worker * 635*0e209d39SAndroid Build Coastguard Worker * - U_COMPARE_CODE_POINT_ORDER 636*0e209d39SAndroid Build Coastguard Worker * Set to choose code point order instead of code unit order 637*0e209d39SAndroid Build Coastguard Worker * (see u_strCompare for details). 638*0e209d39SAndroid Build Coastguard Worker * 639*0e209d39SAndroid Build Coastguard Worker * - U_FOLD_CASE_EXCLUDE_SPECIAL_I 640*0e209d39SAndroid Build Coastguard Worker * 641*0e209d39SAndroid Build Coastguard Worker * @return A negative, zero, or positive integer indicating the comparison result. 642*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 643*0e209d39SAndroid Build Coastguard Worker */ 644*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 645*0e209d39SAndroid Build Coastguard Worker u_strncasecmp(const UChar *s1, const UChar *s2, int32_t n, uint32_t options) __INTRODUCED_IN(31); 646*0e209d39SAndroid Build Coastguard Worker 647*0e209d39SAndroid Build Coastguard Worker 648*0e209d39SAndroid Build Coastguard Worker 649*0e209d39SAndroid Build Coastguard Worker /** 650*0e209d39SAndroid Build Coastguard Worker * Compare two strings case-insensitively using full case folding. 651*0e209d39SAndroid Build Coastguard Worker * This is equivalent to u_strcmp(u_strFoldCase(s1, n, options), 652*0e209d39SAndroid Build Coastguard Worker * u_strFoldCase(s2, n, options)). 653*0e209d39SAndroid Build Coastguard Worker * 654*0e209d39SAndroid Build Coastguard Worker * @param s1 A string to compare. 655*0e209d39SAndroid Build Coastguard Worker * @param s2 A string to compare. 656*0e209d39SAndroid Build Coastguard Worker * @param length The number of characters in each string to case-fold and then compare. 657*0e209d39SAndroid Build Coastguard Worker * @param options A bit set of options: 658*0e209d39SAndroid Build Coastguard Worker * - U_FOLD_CASE_DEFAULT or 0 is used for default options: 659*0e209d39SAndroid Build Coastguard Worker * Comparison in code unit order with default case folding. 660*0e209d39SAndroid Build Coastguard Worker * 661*0e209d39SAndroid Build Coastguard Worker * - U_COMPARE_CODE_POINT_ORDER 662*0e209d39SAndroid Build Coastguard Worker * Set to choose code point order instead of code unit order 663*0e209d39SAndroid Build Coastguard Worker * (see u_strCompare for details). 664*0e209d39SAndroid Build Coastguard Worker * 665*0e209d39SAndroid Build Coastguard Worker * - U_FOLD_CASE_EXCLUDE_SPECIAL_I 666*0e209d39SAndroid Build Coastguard Worker * 667*0e209d39SAndroid Build Coastguard Worker * @return A negative, zero, or positive integer indicating the comparison result. 668*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 669*0e209d39SAndroid Build Coastguard Worker */ 670*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 671*0e209d39SAndroid Build Coastguard Worker u_memcasecmp(const UChar *s1, const UChar *s2, int32_t length, uint32_t options) __INTRODUCED_IN(31); 672*0e209d39SAndroid Build Coastguard Worker 673*0e209d39SAndroid Build Coastguard Worker 674*0e209d39SAndroid Build Coastguard Worker 675*0e209d39SAndroid Build Coastguard Worker /** 676*0e209d39SAndroid Build Coastguard Worker * Copy a ustring. Adds a null terminator. 677*0e209d39SAndroid Build Coastguard Worker * 678*0e209d39SAndroid Build Coastguard Worker * @param dst The destination string. 679*0e209d39SAndroid Build Coastguard Worker * @param src The source string. 680*0e209d39SAndroid Build Coastguard Worker * @return A pointer to <code>dst</code>. 681*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 682*0e209d39SAndroid Build Coastguard Worker */ 683*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar* U_EXPORT2 684*0e209d39SAndroid Build Coastguard Worker u_strcpy(UChar *dst, 685*0e209d39SAndroid Build Coastguard Worker const UChar *src) __INTRODUCED_IN(31); 686*0e209d39SAndroid Build Coastguard Worker 687*0e209d39SAndroid Build Coastguard Worker 688*0e209d39SAndroid Build Coastguard Worker 689*0e209d39SAndroid Build Coastguard Worker /** 690*0e209d39SAndroid Build Coastguard Worker * Copy a ustring. 691*0e209d39SAndroid Build Coastguard Worker * Copies at most <code>n</code> characters. The result will be null terminated 692*0e209d39SAndroid Build Coastguard Worker * if the length of <code>src</code> is less than <code>n</code>. 693*0e209d39SAndroid Build Coastguard Worker * 694*0e209d39SAndroid Build Coastguard Worker * @param dst The destination string. 695*0e209d39SAndroid Build Coastguard Worker * @param src The source string (can be NULL/invalid if n<=0). 696*0e209d39SAndroid Build Coastguard Worker * @param n The maximum number of characters to copy; no-op if <=0. 697*0e209d39SAndroid Build Coastguard Worker * @return A pointer to <code>dst</code>. 698*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 699*0e209d39SAndroid Build Coastguard Worker */ 700*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar* U_EXPORT2 701*0e209d39SAndroid Build Coastguard Worker u_strncpy(UChar *dst, 702*0e209d39SAndroid Build Coastguard Worker const UChar *src, 703*0e209d39SAndroid Build Coastguard Worker int32_t n) __INTRODUCED_IN(31); 704*0e209d39SAndroid Build Coastguard Worker 705*0e209d39SAndroid Build Coastguard Worker 706*0e209d39SAndroid Build Coastguard Worker 707*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_CONVERSION 708*0e209d39SAndroid Build Coastguard Worker 709*0e209d39SAndroid Build Coastguard Worker 710*0e209d39SAndroid Build Coastguard Worker 711*0e209d39SAndroid Build Coastguard Worker 712*0e209d39SAndroid Build Coastguard Worker 713*0e209d39SAndroid Build Coastguard Worker 714*0e209d39SAndroid Build Coastguard Worker 715*0e209d39SAndroid Build Coastguard Worker 716*0e209d39SAndroid Build Coastguard Worker 717*0e209d39SAndroid Build Coastguard Worker #endif 718*0e209d39SAndroid Build Coastguard Worker 719*0e209d39SAndroid Build Coastguard Worker /** 720*0e209d39SAndroid Build Coastguard Worker * Synonym for memcpy(), but with UChars only. 721*0e209d39SAndroid Build Coastguard Worker * @param dest The destination string 722*0e209d39SAndroid Build Coastguard Worker * @param src The source string (can be NULL/invalid if count<=0) 723*0e209d39SAndroid Build Coastguard Worker * @param count The number of characters to copy; no-op if <=0 724*0e209d39SAndroid Build Coastguard Worker * @return A pointer to <code>dest</code> 725*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 726*0e209d39SAndroid Build Coastguard Worker */ 727*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar* U_EXPORT2 728*0e209d39SAndroid Build Coastguard Worker u_memcpy(UChar *dest, const UChar *src, int32_t count) __INTRODUCED_IN(31); 729*0e209d39SAndroid Build Coastguard Worker 730*0e209d39SAndroid Build Coastguard Worker 731*0e209d39SAndroid Build Coastguard Worker 732*0e209d39SAndroid Build Coastguard Worker /** 733*0e209d39SAndroid Build Coastguard Worker * Synonym for memmove(), but with UChars only. 734*0e209d39SAndroid Build Coastguard Worker * @param dest The destination string 735*0e209d39SAndroid Build Coastguard Worker * @param src The source string (can be NULL/invalid if count<=0) 736*0e209d39SAndroid Build Coastguard Worker * @param count The number of characters to move; no-op if <=0 737*0e209d39SAndroid Build Coastguard Worker * @return A pointer to <code>dest</code> 738*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 739*0e209d39SAndroid Build Coastguard Worker */ 740*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar* U_EXPORT2 741*0e209d39SAndroid Build Coastguard Worker u_memmove(UChar *dest, const UChar *src, int32_t count) __INTRODUCED_IN(31); 742*0e209d39SAndroid Build Coastguard Worker 743*0e209d39SAndroid Build Coastguard Worker 744*0e209d39SAndroid Build Coastguard Worker 745*0e209d39SAndroid Build Coastguard Worker /** 746*0e209d39SAndroid Build Coastguard Worker * Initialize <code>count</code> characters of <code>dest</code> to <code>c</code>. 747*0e209d39SAndroid Build Coastguard Worker * 748*0e209d39SAndroid Build Coastguard Worker * @param dest The destination string. 749*0e209d39SAndroid Build Coastguard Worker * @param c The character to initialize the string. 750*0e209d39SAndroid Build Coastguard Worker * @param count The maximum number of characters to set. 751*0e209d39SAndroid Build Coastguard Worker * @return A pointer to <code>dest</code>. 752*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 753*0e209d39SAndroid Build Coastguard Worker */ 754*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar* U_EXPORT2 755*0e209d39SAndroid Build Coastguard Worker u_memset(UChar *dest, UChar c, int32_t count) __INTRODUCED_IN(31); 756*0e209d39SAndroid Build Coastguard Worker 757*0e209d39SAndroid Build Coastguard Worker 758*0e209d39SAndroid Build Coastguard Worker 759*0e209d39SAndroid Build Coastguard Worker /** 760*0e209d39SAndroid Build Coastguard Worker * Compare the first <code>count</code> UChars of each buffer. 761*0e209d39SAndroid Build Coastguard Worker * 762*0e209d39SAndroid Build Coastguard Worker * @param buf1 The first string to compare. 763*0e209d39SAndroid Build Coastguard Worker * @param buf2 The second string to compare. 764*0e209d39SAndroid Build Coastguard Worker * @param count The maximum number of UChars to compare. 765*0e209d39SAndroid Build Coastguard Worker * @return When buf1 < buf2, a negative number is returned. 766*0e209d39SAndroid Build Coastguard Worker * When buf1 == buf2, 0 is returned. 767*0e209d39SAndroid Build Coastguard Worker * When buf1 > buf2, a positive number is returned. 768*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 769*0e209d39SAndroid Build Coastguard Worker */ 770*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 771*0e209d39SAndroid Build Coastguard Worker u_memcmp(const UChar *buf1, const UChar *buf2, int32_t count) __INTRODUCED_IN(31); 772*0e209d39SAndroid Build Coastguard Worker 773*0e209d39SAndroid Build Coastguard Worker 774*0e209d39SAndroid Build Coastguard Worker 775*0e209d39SAndroid Build Coastguard Worker /** 776*0e209d39SAndroid Build Coastguard Worker * Compare two Unicode strings in code point order. 777*0e209d39SAndroid Build Coastguard Worker * This is different in UTF-16 from u_memcmp() if supplementary characters are present. 778*0e209d39SAndroid Build Coastguard Worker * For details, see u_strCompare(). 779*0e209d39SAndroid Build Coastguard Worker * 780*0e209d39SAndroid Build Coastguard Worker * @param s1 A string to compare. 781*0e209d39SAndroid Build Coastguard Worker * @param s2 A string to compare. 782*0e209d39SAndroid Build Coastguard Worker * @param count The maximum number of characters to compare. 783*0e209d39SAndroid Build Coastguard Worker * @return a negative/zero/positive integer corresponding to whether 784*0e209d39SAndroid Build Coastguard Worker * the first string is less than/equal to/greater than the second one 785*0e209d39SAndroid Build Coastguard Worker * in code point order 786*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 787*0e209d39SAndroid Build Coastguard Worker */ 788*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 789*0e209d39SAndroid Build Coastguard Worker u_memcmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t count) __INTRODUCED_IN(31); 790*0e209d39SAndroid Build Coastguard Worker 791*0e209d39SAndroid Build Coastguard Worker 792*0e209d39SAndroid Build Coastguard Worker 793*0e209d39SAndroid Build Coastguard Worker /** 794*0e209d39SAndroid Build Coastguard Worker * Find the first occurrence of a BMP code point in a string. 795*0e209d39SAndroid Build Coastguard Worker * A surrogate code point is found only if its match in the text is not 796*0e209d39SAndroid Build Coastguard Worker * part of a surrogate pair. 797*0e209d39SAndroid Build Coastguard Worker * A NUL character is found at the string terminator. 798*0e209d39SAndroid Build Coastguard Worker * 799*0e209d39SAndroid Build Coastguard Worker * @param s The string to search (contains <code>count</code> UChars). 800*0e209d39SAndroid Build Coastguard Worker * @param c The BMP code point to find. 801*0e209d39SAndroid Build Coastguard Worker * @param count The length of the string. 802*0e209d39SAndroid Build Coastguard Worker * @return A pointer to the first occurrence of <code>c</code> in <code>s</code> 803*0e209d39SAndroid Build Coastguard Worker * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. 804*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 805*0e209d39SAndroid Build Coastguard Worker * 806*0e209d39SAndroid Build Coastguard Worker * @see u_strchr 807*0e209d39SAndroid Build Coastguard Worker * @see u_memchr32 808*0e209d39SAndroid Build Coastguard Worker * @see u_strFindFirst 809*0e209d39SAndroid Build Coastguard Worker */ 810*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar* U_EXPORT2 811*0e209d39SAndroid Build Coastguard Worker u_memchr(const UChar *s, UChar c, int32_t count) __INTRODUCED_IN(31); 812*0e209d39SAndroid Build Coastguard Worker 813*0e209d39SAndroid Build Coastguard Worker 814*0e209d39SAndroid Build Coastguard Worker 815*0e209d39SAndroid Build Coastguard Worker /** 816*0e209d39SAndroid Build Coastguard Worker * Find the first occurrence of a code point in a string. 817*0e209d39SAndroid Build Coastguard Worker * A surrogate code point is found only if its match in the text is not 818*0e209d39SAndroid Build Coastguard Worker * part of a surrogate pair. 819*0e209d39SAndroid Build Coastguard Worker * A NUL character is found at the string terminator. 820*0e209d39SAndroid Build Coastguard Worker * 821*0e209d39SAndroid Build Coastguard Worker * @param s The string to search (contains <code>count</code> UChars). 822*0e209d39SAndroid Build Coastguard Worker * @param c The code point to find. 823*0e209d39SAndroid Build Coastguard Worker * @param count The length of the string. 824*0e209d39SAndroid Build Coastguard Worker * @return A pointer to the first occurrence of <code>c</code> in <code>s</code> 825*0e209d39SAndroid Build Coastguard Worker * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. 826*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 827*0e209d39SAndroid Build Coastguard Worker * 828*0e209d39SAndroid Build Coastguard Worker * @see u_strchr32 829*0e209d39SAndroid Build Coastguard Worker * @see u_memchr 830*0e209d39SAndroid Build Coastguard Worker * @see u_strFindFirst 831*0e209d39SAndroid Build Coastguard Worker */ 832*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar* U_EXPORT2 833*0e209d39SAndroid Build Coastguard Worker u_memchr32(const UChar *s, UChar32 c, int32_t count) __INTRODUCED_IN(31); 834*0e209d39SAndroid Build Coastguard Worker 835*0e209d39SAndroid Build Coastguard Worker 836*0e209d39SAndroid Build Coastguard Worker 837*0e209d39SAndroid Build Coastguard Worker /** 838*0e209d39SAndroid Build Coastguard Worker * Find the last occurrence of a BMP code point in a string. 839*0e209d39SAndroid Build Coastguard Worker * A surrogate code point is found only if its match in the text is not 840*0e209d39SAndroid Build Coastguard Worker * part of a surrogate pair. 841*0e209d39SAndroid Build Coastguard Worker * A NUL character is found at the string terminator. 842*0e209d39SAndroid Build Coastguard Worker * 843*0e209d39SAndroid Build Coastguard Worker * @param s The string to search (contains <code>count</code> UChars). 844*0e209d39SAndroid Build Coastguard Worker * @param c The BMP code point to find. 845*0e209d39SAndroid Build Coastguard Worker * @param count The length of the string. 846*0e209d39SAndroid Build Coastguard Worker * @return A pointer to the last occurrence of <code>c</code> in <code>s</code> 847*0e209d39SAndroid Build Coastguard Worker * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. 848*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.4 849*0e209d39SAndroid Build Coastguard Worker * 850*0e209d39SAndroid Build Coastguard Worker * @see u_strrchr 851*0e209d39SAndroid Build Coastguard Worker * @see u_memrchr32 852*0e209d39SAndroid Build Coastguard Worker * @see u_strFindLast 853*0e209d39SAndroid Build Coastguard Worker */ 854*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar* U_EXPORT2 855*0e209d39SAndroid Build Coastguard Worker u_memrchr(const UChar *s, UChar c, int32_t count) __INTRODUCED_IN(31); 856*0e209d39SAndroid Build Coastguard Worker 857*0e209d39SAndroid Build Coastguard Worker 858*0e209d39SAndroid Build Coastguard Worker 859*0e209d39SAndroid Build Coastguard Worker /** 860*0e209d39SAndroid Build Coastguard Worker * Find the last occurrence of a code point in a string. 861*0e209d39SAndroid Build Coastguard Worker * A surrogate code point is found only if its match in the text is not 862*0e209d39SAndroid Build Coastguard Worker * part of a surrogate pair. 863*0e209d39SAndroid Build Coastguard Worker * A NUL character is found at the string terminator. 864*0e209d39SAndroid Build Coastguard Worker * 865*0e209d39SAndroid Build Coastguard Worker * @param s The string to search (contains <code>count</code> UChars). 866*0e209d39SAndroid Build Coastguard Worker * @param c The code point to find. 867*0e209d39SAndroid Build Coastguard Worker * @param count The length of the string. 868*0e209d39SAndroid Build Coastguard Worker * @return A pointer to the last occurrence of <code>c</code> in <code>s</code> 869*0e209d39SAndroid Build Coastguard Worker * or <code>NULL</code> if <code>c</code> is not in <code>s</code>. 870*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.4 871*0e209d39SAndroid Build Coastguard Worker * 872*0e209d39SAndroid Build Coastguard Worker * @see u_strrchr32 873*0e209d39SAndroid Build Coastguard Worker * @see u_memrchr 874*0e209d39SAndroid Build Coastguard Worker * @see u_strFindLast 875*0e209d39SAndroid Build Coastguard Worker */ 876*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar* U_EXPORT2 877*0e209d39SAndroid Build Coastguard Worker u_memrchr32(const UChar *s, UChar32 c, int32_t count) __INTRODUCED_IN(31); 878*0e209d39SAndroid Build Coastguard Worker 879*0e209d39SAndroid Build Coastguard Worker 880*0e209d39SAndroid Build Coastguard Worker 881*0e209d39SAndroid Build Coastguard Worker /** 882*0e209d39SAndroid Build Coastguard Worker * Unicode String literals in C. 883*0e209d39SAndroid Build Coastguard Worker * We need one macro to declare a variable for the string 884*0e209d39SAndroid Build Coastguard Worker * and to statically preinitialize it if possible, 885*0e209d39SAndroid Build Coastguard Worker * and a second macro to dynamically initialize such a string variable if necessary. 886*0e209d39SAndroid Build Coastguard Worker * 887*0e209d39SAndroid Build Coastguard Worker * The macros are defined for maximum performance. 888*0e209d39SAndroid Build Coastguard Worker * They work only for strings that contain "invariant characters", i.e., 889*0e209d39SAndroid Build Coastguard Worker * only latin letters, digits, and some punctuation. 890*0e209d39SAndroid Build Coastguard Worker * See utypes.h for details. 891*0e209d39SAndroid Build Coastguard Worker * 892*0e209d39SAndroid Build Coastguard Worker * A pair of macros for a single string must be used with the same 893*0e209d39SAndroid Build Coastguard Worker * parameters. 894*0e209d39SAndroid Build Coastguard Worker * The string parameter must be a C string literal. 895*0e209d39SAndroid Build Coastguard Worker * The length of the string, not including the terminating 896*0e209d39SAndroid Build Coastguard Worker * `NUL`, must be specified as a constant. 897*0e209d39SAndroid Build Coastguard Worker * The U_STRING_DECL macro should be invoked exactly once for one 898*0e209d39SAndroid Build Coastguard Worker * such string variable before it is used. 899*0e209d39SAndroid Build Coastguard Worker * 900*0e209d39SAndroid Build Coastguard Worker * Usage: 901*0e209d39SAndroid Build Coastguard Worker * 902*0e209d39SAndroid Build Coastguard Worker * U_STRING_DECL(ustringVar1, "Quick-Fox 2", 11); 903*0e209d39SAndroid Build Coastguard Worker * U_STRING_DECL(ustringVar2, "jumps 5%", 8); 904*0e209d39SAndroid Build Coastguard Worker * static UBool didInit=false; 905*0e209d39SAndroid Build Coastguard Worker * 906*0e209d39SAndroid Build Coastguard Worker * int32_t function() { 907*0e209d39SAndroid Build Coastguard Worker * if(!didInit) { 908*0e209d39SAndroid Build Coastguard Worker * U_STRING_INIT(ustringVar1, "Quick-Fox 2", 11); 909*0e209d39SAndroid Build Coastguard Worker * U_STRING_INIT(ustringVar2, "jumps 5%", 8); 910*0e209d39SAndroid Build Coastguard Worker * didInit=true; 911*0e209d39SAndroid Build Coastguard Worker * } 912*0e209d39SAndroid Build Coastguard Worker * return u_strcmp(ustringVar1, ustringVar2); 913*0e209d39SAndroid Build Coastguard Worker * } 914*0e209d39SAndroid Build Coastguard Worker * 915*0e209d39SAndroid Build Coastguard Worker * Note that the macros will NOT consistently work if their argument is another #`define`. 916*0e209d39SAndroid Build Coastguard Worker * The following will not work on all platforms, don't use it. 917*0e209d39SAndroid Build Coastguard Worker * 918*0e209d39SAndroid Build Coastguard Worker * #define GLUCK "Mr. Gluck" 919*0e209d39SAndroid Build Coastguard Worker * U_STRING_DECL(var, GLUCK, 9) 920*0e209d39SAndroid Build Coastguard Worker * U_STRING_INIT(var, GLUCK, 9) 921*0e209d39SAndroid Build Coastguard Worker * 922*0e209d39SAndroid Build Coastguard Worker * Instead, use the string literal "Mr. Gluck" as the argument to both macro 923*0e209d39SAndroid Build Coastguard Worker * calls. 924*0e209d39SAndroid Build Coastguard Worker * 925*0e209d39SAndroid Build Coastguard Worker * 926*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 927*0e209d39SAndroid Build Coastguard Worker */ 928*0e209d39SAndroid Build Coastguard Worker #if defined(U_DECLARE_UTF16) 929*0e209d39SAndroid Build Coastguard Worker # define U_STRING_DECL(var, cs, length) static const UChar *var=(const UChar *)U_DECLARE_UTF16(cs) 930*0e209d39SAndroid Build Coastguard Worker /**\xrefitem stable "Stable" "Stable List" ICU 2.0 */ 931*0e209d39SAndroid Build Coastguard Worker # define U_STRING_INIT(var, cs, length) 932*0e209d39SAndroid Build Coastguard Worker #elif U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && (U_CHARSET_FAMILY==U_ASCII_FAMILY || defined(U_WCHAR_IS_UTF16)) 933*0e209d39SAndroid Build Coastguard Worker # define U_STRING_DECL(var, cs, length) static const UChar var[(length)+1]=L ## cs 934*0e209d39SAndroid Build Coastguard Worker /**\xrefitem stable "Stable" "Stable List" ICU 2.0 */ 935*0e209d39SAndroid Build Coastguard Worker # define U_STRING_INIT(var, cs, length) 936*0e209d39SAndroid Build Coastguard Worker #else 937*0e209d39SAndroid Build Coastguard Worker # define U_STRING_DECL(var, cs, length) static UChar var[(length)+1] 938*0e209d39SAndroid Build Coastguard Worker /**\xrefitem stable "Stable" "Stable List" ICU 2.0 */ 939*0e209d39SAndroid Build Coastguard Worker # define U_STRING_INIT(var, cs, length) u_charsToUChars(cs, var, length+1) 940*0e209d39SAndroid Build Coastguard Worker #endif 941*0e209d39SAndroid Build Coastguard Worker 942*0e209d39SAndroid Build Coastguard Worker 943*0e209d39SAndroid Build Coastguard Worker 944*0e209d39SAndroid Build Coastguard Worker U_CDECL_BEGIN 945*0e209d39SAndroid Build Coastguard Worker /** 946*0e209d39SAndroid Build Coastguard Worker * Callback function for u_unescapeAt() that returns a character of 947*0e209d39SAndroid Build Coastguard Worker * the source text given an offset and a context pointer. The context 948*0e209d39SAndroid Build Coastguard Worker * pointer will be whatever is passed into u_unescapeAt(). 949*0e209d39SAndroid Build Coastguard Worker * 950*0e209d39SAndroid Build Coastguard Worker * @param offset pointer to the offset that will be passed to u_unescapeAt(). 951*0e209d39SAndroid Build Coastguard Worker * @param context an opaque pointer passed directly into u_unescapeAt() 952*0e209d39SAndroid Build Coastguard Worker * @return the character represented by the escape sequence at 953*0e209d39SAndroid Build Coastguard Worker * offset 954*0e209d39SAndroid Build Coastguard Worker * @see u_unescapeAt 955*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 956*0e209d39SAndroid Build Coastguard Worker */ 957*0e209d39SAndroid Build Coastguard Worker typedef UChar (U_CALLCONV *UNESCAPE_CHAR_AT)(int32_t offset, void *context); 958*0e209d39SAndroid Build Coastguard Worker U_CDECL_END 959*0e209d39SAndroid Build Coastguard Worker 960*0e209d39SAndroid Build Coastguard Worker 961*0e209d39SAndroid Build Coastguard Worker 962*0e209d39SAndroid Build Coastguard Worker /** 963*0e209d39SAndroid Build Coastguard Worker * Uppercase the characters in a string. 964*0e209d39SAndroid Build Coastguard Worker * Casing is locale-dependent and context-sensitive. 965*0e209d39SAndroid Build Coastguard Worker * The result may be longer or shorter than the original. 966*0e209d39SAndroid Build Coastguard Worker * The source string and the destination buffer are allowed to overlap. 967*0e209d39SAndroid Build Coastguard Worker * 968*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be zero-terminated if 969*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 970*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of UChars). If it is 0, then 971*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the result 972*0e209d39SAndroid Build Coastguard Worker * without writing any of the result string. 973*0e209d39SAndroid Build Coastguard Worker * @param src The original string 974*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be zero-terminated. 975*0e209d39SAndroid Build Coastguard Worker * @param locale The locale to consider, or "" for the root locale or NULL for the default locale. 976*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 977*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 978*0e209d39SAndroid Build Coastguard Worker * @return The length of the result string. It may be greater than destCapacity. In that case, 979*0e209d39SAndroid Build Coastguard Worker * only some of the result was written to the destination buffer. 980*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 981*0e209d39SAndroid Build Coastguard Worker */ 982*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 983*0e209d39SAndroid Build Coastguard Worker u_strToUpper(UChar *dest, int32_t destCapacity, 984*0e209d39SAndroid Build Coastguard Worker const UChar *src, int32_t srcLength, 985*0e209d39SAndroid Build Coastguard Worker const char *locale, 986*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(31); 987*0e209d39SAndroid Build Coastguard Worker 988*0e209d39SAndroid Build Coastguard Worker 989*0e209d39SAndroid Build Coastguard Worker 990*0e209d39SAndroid Build Coastguard Worker /** 991*0e209d39SAndroid Build Coastguard Worker * Lowercase the characters in a string. 992*0e209d39SAndroid Build Coastguard Worker * Casing is locale-dependent and context-sensitive. 993*0e209d39SAndroid Build Coastguard Worker * The result may be longer or shorter than the original. 994*0e209d39SAndroid Build Coastguard Worker * The source string and the destination buffer are allowed to overlap. 995*0e209d39SAndroid Build Coastguard Worker * 996*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be zero-terminated if 997*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 998*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of UChars). If it is 0, then 999*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the result 1000*0e209d39SAndroid Build Coastguard Worker * without writing any of the result string. 1001*0e209d39SAndroid Build Coastguard Worker * @param src The original string 1002*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be zero-terminated. 1003*0e209d39SAndroid Build Coastguard Worker * @param locale The locale to consider, or "" for the root locale or NULL for the default locale. 1004*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 1005*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 1006*0e209d39SAndroid Build Coastguard Worker * @return The length of the result string. It may be greater than destCapacity. In that case, 1007*0e209d39SAndroid Build Coastguard Worker * only some of the result was written to the destination buffer. 1008*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 1009*0e209d39SAndroid Build Coastguard Worker */ 1010*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1011*0e209d39SAndroid Build Coastguard Worker u_strToLower(UChar *dest, int32_t destCapacity, 1012*0e209d39SAndroid Build Coastguard Worker const UChar *src, int32_t srcLength, 1013*0e209d39SAndroid Build Coastguard Worker const char *locale, 1014*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(31); 1015*0e209d39SAndroid Build Coastguard Worker 1016*0e209d39SAndroid Build Coastguard Worker 1017*0e209d39SAndroid Build Coastguard Worker 1018*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_BREAK_ITERATION 1019*0e209d39SAndroid Build Coastguard Worker 1020*0e209d39SAndroid Build Coastguard Worker /** 1021*0e209d39SAndroid Build Coastguard Worker * Titlecase a string. 1022*0e209d39SAndroid Build Coastguard Worker * Casing is locale-dependent and context-sensitive. 1023*0e209d39SAndroid Build Coastguard Worker * Titlecasing uses a break iterator to find the first characters of words 1024*0e209d39SAndroid Build Coastguard Worker * that are to be titlecased. It titlecases those characters and lowercases 1025*0e209d39SAndroid Build Coastguard Worker * all others. 1026*0e209d39SAndroid Build Coastguard Worker * 1027*0e209d39SAndroid Build Coastguard Worker * The titlecase break iterator can be provided to customize for arbitrary 1028*0e209d39SAndroid Build Coastguard Worker * styles, using rules and dictionaries beyond the standard iterators. 1029*0e209d39SAndroid Build Coastguard Worker * It may be more efficient to always provide an iterator to avoid 1030*0e209d39SAndroid Build Coastguard Worker * opening and closing one for each string. 1031*0e209d39SAndroid Build Coastguard Worker * The standard titlecase iterator for the root locale implements the 1032*0e209d39SAndroid Build Coastguard Worker * algorithm of Unicode TR 21. 1033*0e209d39SAndroid Build Coastguard Worker * 1034*0e209d39SAndroid Build Coastguard Worker * This function uses only the setText(), first() and next() methods of the 1035*0e209d39SAndroid Build Coastguard Worker * provided break iterator. 1036*0e209d39SAndroid Build Coastguard Worker * 1037*0e209d39SAndroid Build Coastguard Worker * The result may be longer or shorter than the original. 1038*0e209d39SAndroid Build Coastguard Worker * The source string and the destination buffer are allowed to overlap. 1039*0e209d39SAndroid Build Coastguard Worker * 1040*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be zero-terminated if 1041*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 1042*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of UChars). If it is 0, then 1043*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the result 1044*0e209d39SAndroid Build Coastguard Worker * without writing any of the result string. 1045*0e209d39SAndroid Build Coastguard Worker * @param src The original string 1046*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be zero-terminated. 1047*0e209d39SAndroid Build Coastguard Worker * @param titleIter A break iterator to find the first characters of words 1048*0e209d39SAndroid Build Coastguard Worker * that are to be titlecased. 1049*0e209d39SAndroid Build Coastguard Worker * If none is provided (NULL), then a standard titlecase 1050*0e209d39SAndroid Build Coastguard Worker * break iterator is opened. 1051*0e209d39SAndroid Build Coastguard Worker * @param locale The locale to consider, or "" for the root locale or NULL for the default locale. 1052*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 1053*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 1054*0e209d39SAndroid Build Coastguard Worker * @return The length of the result string. It may be greater than destCapacity. In that case, 1055*0e209d39SAndroid Build Coastguard Worker * only some of the result was written to the destination buffer. 1056*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.1 1057*0e209d39SAndroid Build Coastguard Worker */ 1058*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1059*0e209d39SAndroid Build Coastguard Worker u_strToTitle(UChar *dest, int32_t destCapacity, 1060*0e209d39SAndroid Build Coastguard Worker const UChar *src, int32_t srcLength, 1061*0e209d39SAndroid Build Coastguard Worker UBreakIterator *titleIter, 1062*0e209d39SAndroid Build Coastguard Worker const char *locale, 1063*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(31); 1064*0e209d39SAndroid Build Coastguard Worker 1065*0e209d39SAndroid Build Coastguard Worker 1066*0e209d39SAndroid Build Coastguard Worker 1067*0e209d39SAndroid Build Coastguard Worker #endif 1068*0e209d39SAndroid Build Coastguard Worker 1069*0e209d39SAndroid Build Coastguard Worker /** 1070*0e209d39SAndroid Build Coastguard Worker * Case-folds the characters in a string. 1071*0e209d39SAndroid Build Coastguard Worker * 1072*0e209d39SAndroid Build Coastguard Worker * Case-folding is locale-independent and not context-sensitive, 1073*0e209d39SAndroid Build Coastguard Worker * but there is an option for whether to include or exclude mappings for dotted I 1074*0e209d39SAndroid Build Coastguard Worker * and dotless i that are marked with 'T' in CaseFolding.txt. 1075*0e209d39SAndroid Build Coastguard Worker * 1076*0e209d39SAndroid Build Coastguard Worker * The result may be longer or shorter than the original. 1077*0e209d39SAndroid Build Coastguard Worker * The source string and the destination buffer are allowed to overlap. 1078*0e209d39SAndroid Build Coastguard Worker * 1079*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be zero-terminated if 1080*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 1081*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of UChars). If it is 0, then 1082*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the result 1083*0e209d39SAndroid Build Coastguard Worker * without writing any of the result string. 1084*0e209d39SAndroid Build Coastguard Worker * @param src The original string 1085*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be zero-terminated. 1086*0e209d39SAndroid Build Coastguard Worker * @param options Either U_FOLD_CASE_DEFAULT or U_FOLD_CASE_EXCLUDE_SPECIAL_I 1087*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 1088*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 1089*0e209d39SAndroid Build Coastguard Worker * @return The length of the result string. It may be greater than destCapacity. In that case, 1090*0e209d39SAndroid Build Coastguard Worker * only some of the result was written to the destination buffer. 1091*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 1092*0e209d39SAndroid Build Coastguard Worker */ 1093*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1094*0e209d39SAndroid Build Coastguard Worker u_strFoldCase(UChar *dest, int32_t destCapacity, 1095*0e209d39SAndroid Build Coastguard Worker const UChar *src, int32_t srcLength, 1096*0e209d39SAndroid Build Coastguard Worker uint32_t options, 1097*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(31); 1098*0e209d39SAndroid Build Coastguard Worker 1099*0e209d39SAndroid Build Coastguard Worker 1100*0e209d39SAndroid Build Coastguard Worker 1101*0e209d39SAndroid Build Coastguard Worker #if defined(U_WCHAR_IS_UTF16) || defined(U_WCHAR_IS_UTF32) || !UCONFIG_NO_CONVERSION 1102*0e209d39SAndroid Build Coastguard Worker 1103*0e209d39SAndroid Build Coastguard Worker 1104*0e209d39SAndroid Build Coastguard Worker #endif /* defined(U_WCHAR_IS_UTF16) || defined(U_WCHAR_IS_UTF32) || !UCONFIG_NO_CONVERSION */ 1105*0e209d39SAndroid Build Coastguard Worker 1106*0e209d39SAndroid Build Coastguard Worker /** 1107*0e209d39SAndroid Build Coastguard Worker * Convert a UTF-16 string to UTF-8. 1108*0e209d39SAndroid Build Coastguard Worker * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set. 1109*0e209d39SAndroid Build Coastguard Worker * 1110*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be zero-terminated if 1111*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 1112*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of chars). If it is 0, then 1113*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the 1114*0e209d39SAndroid Build Coastguard Worker * result without writing any of the result string (pre-flighting). 1115*0e209d39SAndroid Build Coastguard Worker * @param pDestLength A pointer to receive the number of units written to the destination. If 1116*0e209d39SAndroid Build Coastguard Worker * pDestLength!=NULL then *pDestLength is always set to the 1117*0e209d39SAndroid Build Coastguard Worker * number of output units corresponding to the transformation of 1118*0e209d39SAndroid Build Coastguard Worker * all the input units, even in case of a buffer overflow. 1119*0e209d39SAndroid Build Coastguard Worker * @param src The original source string 1120*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be zero-terminated. 1121*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 1122*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 1123*0e209d39SAndroid Build Coastguard Worker * @return The pointer to destination buffer. 1124*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 1125*0e209d39SAndroid Build Coastguard Worker * @see u_strToUTF8WithSub 1126*0e209d39SAndroid Build Coastguard Worker * @see u_strFromUTF8 1127*0e209d39SAndroid Build Coastguard Worker */ 1128*0e209d39SAndroid Build Coastguard Worker U_CAPI char* U_EXPORT2 1129*0e209d39SAndroid Build Coastguard Worker u_strToUTF8(char *dest, 1130*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 1131*0e209d39SAndroid Build Coastguard Worker int32_t *pDestLength, 1132*0e209d39SAndroid Build Coastguard Worker const UChar *src, 1133*0e209d39SAndroid Build Coastguard Worker int32_t srcLength, 1134*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(31); 1135*0e209d39SAndroid Build Coastguard Worker 1136*0e209d39SAndroid Build Coastguard Worker 1137*0e209d39SAndroid Build Coastguard Worker 1138*0e209d39SAndroid Build Coastguard Worker /** 1139*0e209d39SAndroid Build Coastguard Worker * Convert a UTF-8 string to UTF-16. 1140*0e209d39SAndroid Build Coastguard Worker * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set. 1141*0e209d39SAndroid Build Coastguard Worker * 1142*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be zero-terminated if 1143*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 1144*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of UChars). If it is 0, then 1145*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the 1146*0e209d39SAndroid Build Coastguard Worker * result without writing any of the result string (pre-flighting). 1147*0e209d39SAndroid Build Coastguard Worker * @param pDestLength A pointer to receive the number of units written to the destination. If 1148*0e209d39SAndroid Build Coastguard Worker * pDestLength!=NULL then *pDestLength is always set to the 1149*0e209d39SAndroid Build Coastguard Worker * number of output units corresponding to the transformation of 1150*0e209d39SAndroid Build Coastguard Worker * all the input units, even in case of a buffer overflow. 1151*0e209d39SAndroid Build Coastguard Worker * @param src The original source string 1152*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be zero-terminated. 1153*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 1154*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 1155*0e209d39SAndroid Build Coastguard Worker * @return The pointer to destination buffer. 1156*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 1157*0e209d39SAndroid Build Coastguard Worker * @see u_strFromUTF8WithSub 1158*0e209d39SAndroid Build Coastguard Worker * @see u_strFromUTF8Lenient 1159*0e209d39SAndroid Build Coastguard Worker */ 1160*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar* U_EXPORT2 1161*0e209d39SAndroid Build Coastguard Worker u_strFromUTF8(UChar *dest, 1162*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 1163*0e209d39SAndroid Build Coastguard Worker int32_t *pDestLength, 1164*0e209d39SAndroid Build Coastguard Worker const char *src, 1165*0e209d39SAndroid Build Coastguard Worker int32_t srcLength, 1166*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(31); 1167*0e209d39SAndroid Build Coastguard Worker 1168*0e209d39SAndroid Build Coastguard Worker 1169*0e209d39SAndroid Build Coastguard Worker 1170*0e209d39SAndroid Build Coastguard Worker /** 1171*0e209d39SAndroid Build Coastguard Worker * Convert a UTF-16 string to UTF-8. 1172*0e209d39SAndroid Build Coastguard Worker * 1173*0e209d39SAndroid Build Coastguard Worker * Same as u_strToUTF8() except for the additional subchar which is output for 1174*0e209d39SAndroid Build Coastguard Worker * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code. 1175*0e209d39SAndroid Build Coastguard Worker * With subchar==U_SENTINEL, this function behaves exactly like u_strToUTF8(). 1176*0e209d39SAndroid Build Coastguard Worker * 1177*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be zero-terminated if 1178*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 1179*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of chars). If it is 0, then 1180*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the 1181*0e209d39SAndroid Build Coastguard Worker * result without writing any of the result string (pre-flighting). 1182*0e209d39SAndroid Build Coastguard Worker * @param pDestLength A pointer to receive the number of units written to the destination. If 1183*0e209d39SAndroid Build Coastguard Worker * pDestLength!=NULL then *pDestLength is always set to the 1184*0e209d39SAndroid Build Coastguard Worker * number of output units corresponding to the transformation of 1185*0e209d39SAndroid Build Coastguard Worker * all the input units, even in case of a buffer overflow. 1186*0e209d39SAndroid Build Coastguard Worker * @param src The original source string 1187*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be zero-terminated. 1188*0e209d39SAndroid Build Coastguard Worker * @param subchar The substitution character to use in place of an illegal input sequence, 1189*0e209d39SAndroid Build Coastguard Worker * or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead. 1190*0e209d39SAndroid Build Coastguard Worker * A substitution character can be any valid Unicode code point (up to U+10FFFF) 1191*0e209d39SAndroid Build Coastguard Worker * except for surrogate code points (U+D800..U+DFFF). 1192*0e209d39SAndroid Build Coastguard Worker * The recommended value is U+FFFD "REPLACEMENT CHARACTER". 1193*0e209d39SAndroid Build Coastguard Worker * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0. 1194*0e209d39SAndroid Build Coastguard Worker * Set to 0 if no substitutions occur or subchar<0. 1195*0e209d39SAndroid Build Coastguard Worker * pNumSubstitutions can be NULL. 1196*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Pointer to a standard ICU error code. Its input value must 1197*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns 1198*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with 1199*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.) 1200*0e209d39SAndroid Build Coastguard Worker * @return The pointer to destination buffer. 1201*0e209d39SAndroid Build Coastguard Worker * @see u_strToUTF8 1202*0e209d39SAndroid Build Coastguard Worker * @see u_strFromUTF8WithSub 1203*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 3.6 1204*0e209d39SAndroid Build Coastguard Worker */ 1205*0e209d39SAndroid Build Coastguard Worker U_CAPI char* U_EXPORT2 1206*0e209d39SAndroid Build Coastguard Worker u_strToUTF8WithSub(char *dest, 1207*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 1208*0e209d39SAndroid Build Coastguard Worker int32_t *pDestLength, 1209*0e209d39SAndroid Build Coastguard Worker const UChar *src, 1210*0e209d39SAndroid Build Coastguard Worker int32_t srcLength, 1211*0e209d39SAndroid Build Coastguard Worker UChar32 subchar, int32_t *pNumSubstitutions, 1212*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(31); 1213*0e209d39SAndroid Build Coastguard Worker 1214*0e209d39SAndroid Build Coastguard Worker 1215*0e209d39SAndroid Build Coastguard Worker 1216*0e209d39SAndroid Build Coastguard Worker /** 1217*0e209d39SAndroid Build Coastguard Worker * Convert a UTF-8 string to UTF-16. 1218*0e209d39SAndroid Build Coastguard Worker * 1219*0e209d39SAndroid Build Coastguard Worker * Same as u_strFromUTF8() except for the additional subchar which is output for 1220*0e209d39SAndroid Build Coastguard Worker * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code. 1221*0e209d39SAndroid Build Coastguard Worker * With subchar==U_SENTINEL, this function behaves exactly like u_strFromUTF8(). 1222*0e209d39SAndroid Build Coastguard Worker * 1223*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be zero-terminated if 1224*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 1225*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of UChars). If it is 0, then 1226*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the 1227*0e209d39SAndroid Build Coastguard Worker * result without writing any of the result string (pre-flighting). 1228*0e209d39SAndroid Build Coastguard Worker * @param pDestLength A pointer to receive the number of units written to the destination. If 1229*0e209d39SAndroid Build Coastguard Worker * pDestLength!=NULL then *pDestLength is always set to the 1230*0e209d39SAndroid Build Coastguard Worker * number of output units corresponding to the transformation of 1231*0e209d39SAndroid Build Coastguard Worker * all the input units, even in case of a buffer overflow. 1232*0e209d39SAndroid Build Coastguard Worker * @param src The original source string 1233*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be zero-terminated. 1234*0e209d39SAndroid Build Coastguard Worker * @param subchar The substitution character to use in place of an illegal input sequence, 1235*0e209d39SAndroid Build Coastguard Worker * or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead. 1236*0e209d39SAndroid Build Coastguard Worker * A substitution character can be any valid Unicode code point (up to U+10FFFF) 1237*0e209d39SAndroid Build Coastguard Worker * except for surrogate code points (U+D800..U+DFFF). 1238*0e209d39SAndroid Build Coastguard Worker * The recommended value is U+FFFD "REPLACEMENT CHARACTER". 1239*0e209d39SAndroid Build Coastguard Worker * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0. 1240*0e209d39SAndroid Build Coastguard Worker * Set to 0 if no substitutions occur or subchar<0. 1241*0e209d39SAndroid Build Coastguard Worker * pNumSubstitutions can be NULL. 1242*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Pointer to a standard ICU error code. Its input value must 1243*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns 1244*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with 1245*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.) 1246*0e209d39SAndroid Build Coastguard Worker * @return The pointer to destination buffer. 1247*0e209d39SAndroid Build Coastguard Worker * @see u_strFromUTF8 1248*0e209d39SAndroid Build Coastguard Worker * @see u_strFromUTF8Lenient 1249*0e209d39SAndroid Build Coastguard Worker * @see u_strToUTF8WithSub 1250*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 3.6 1251*0e209d39SAndroid Build Coastguard Worker */ 1252*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar* U_EXPORT2 1253*0e209d39SAndroid Build Coastguard Worker u_strFromUTF8WithSub(UChar *dest, 1254*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 1255*0e209d39SAndroid Build Coastguard Worker int32_t *pDestLength, 1256*0e209d39SAndroid Build Coastguard Worker const char *src, 1257*0e209d39SAndroid Build Coastguard Worker int32_t srcLength, 1258*0e209d39SAndroid Build Coastguard Worker UChar32 subchar, int32_t *pNumSubstitutions, 1259*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(31); 1260*0e209d39SAndroid Build Coastguard Worker 1261*0e209d39SAndroid Build Coastguard Worker 1262*0e209d39SAndroid Build Coastguard Worker 1263*0e209d39SAndroid Build Coastguard Worker /** 1264*0e209d39SAndroid Build Coastguard Worker * Convert a UTF-8 string to UTF-16. 1265*0e209d39SAndroid Build Coastguard Worker * 1266*0e209d39SAndroid Build Coastguard Worker * Same as u_strFromUTF8() except that this function is designed to be very fast, 1267*0e209d39SAndroid Build Coastguard Worker * which it achieves by being lenient about malformed UTF-8 sequences. 1268*0e209d39SAndroid Build Coastguard Worker * This function is intended for use in environments where UTF-8 text is 1269*0e209d39SAndroid Build Coastguard Worker * expected to be well-formed. 1270*0e209d39SAndroid Build Coastguard Worker * 1271*0e209d39SAndroid Build Coastguard Worker * Its semantics are: 1272*0e209d39SAndroid Build Coastguard Worker * - Well-formed UTF-8 text is correctly converted to well-formed UTF-16 text. 1273*0e209d39SAndroid Build Coastguard Worker * - The function will not read beyond the input string, nor write beyond 1274*0e209d39SAndroid Build Coastguard Worker * the destCapacity. 1275*0e209d39SAndroid Build Coastguard Worker * - Malformed UTF-8 results in "garbage" 16-bit Unicode strings which may not 1276*0e209d39SAndroid Build Coastguard Worker * be well-formed UTF-16. 1277*0e209d39SAndroid Build Coastguard Worker * The function will resynchronize to valid code point boundaries 1278*0e209d39SAndroid Build Coastguard Worker * within a small number of code points after an illegal sequence. 1279*0e209d39SAndroid Build Coastguard Worker * - Non-shortest forms are not detected and will result in "spoofing" output. 1280*0e209d39SAndroid Build Coastguard Worker * 1281*0e209d39SAndroid Build Coastguard Worker * For further performance improvement, if srcLength is given (>=0), 1282*0e209d39SAndroid Build Coastguard Worker * then it must be destCapacity>=srcLength. 1283*0e209d39SAndroid Build Coastguard Worker * 1284*0e209d39SAndroid Build Coastguard Worker * There is no inverse u_strToUTF8Lenient() function because there is practically 1285*0e209d39SAndroid Build Coastguard Worker * no performance gain from not checking that a UTF-16 string is well-formed. 1286*0e209d39SAndroid Build Coastguard Worker * 1287*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be zero-terminated if 1288*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 1289*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of UChars). If it is 0, then 1290*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the 1291*0e209d39SAndroid Build Coastguard Worker * result without writing any of the result string (pre-flighting). 1292*0e209d39SAndroid Build Coastguard Worker * Unlike for other ICU functions, if srcLength>=0 then it 1293*0e209d39SAndroid Build Coastguard Worker * must be destCapacity>=srcLength. 1294*0e209d39SAndroid Build Coastguard Worker * @param pDestLength A pointer to receive the number of units written to the destination. If 1295*0e209d39SAndroid Build Coastguard Worker * pDestLength!=NULL then *pDestLength is always set to the 1296*0e209d39SAndroid Build Coastguard Worker * number of output units corresponding to the transformation of 1297*0e209d39SAndroid Build Coastguard Worker * all the input units, even in case of a buffer overflow. 1298*0e209d39SAndroid Build Coastguard Worker * Unlike for other ICU functions, if srcLength>=0 but 1299*0e209d39SAndroid Build Coastguard Worker * destCapacity<srcLength, then *pDestLength will be set to srcLength 1300*0e209d39SAndroid Build Coastguard Worker * (and U_BUFFER_OVERFLOW_ERROR will be set) 1301*0e209d39SAndroid Build Coastguard Worker * regardless of the actual result length. 1302*0e209d39SAndroid Build Coastguard Worker * @param src The original source string 1303*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be zero-terminated. 1304*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Pointer to a standard ICU error code. Its input value must 1305*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns 1306*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with 1307*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.) 1308*0e209d39SAndroid Build Coastguard Worker * @return The pointer to destination buffer. 1309*0e209d39SAndroid Build Coastguard Worker * @see u_strFromUTF8 1310*0e209d39SAndroid Build Coastguard Worker * @see u_strFromUTF8WithSub 1311*0e209d39SAndroid Build Coastguard Worker * @see u_strToUTF8WithSub 1312*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 3.6 1313*0e209d39SAndroid Build Coastguard Worker */ 1314*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar * U_EXPORT2 1315*0e209d39SAndroid Build Coastguard Worker u_strFromUTF8Lenient(UChar *dest, 1316*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 1317*0e209d39SAndroid Build Coastguard Worker int32_t *pDestLength, 1318*0e209d39SAndroid Build Coastguard Worker const char *src, 1319*0e209d39SAndroid Build Coastguard Worker int32_t srcLength, 1320*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(31); 1321*0e209d39SAndroid Build Coastguard Worker 1322*0e209d39SAndroid Build Coastguard Worker 1323*0e209d39SAndroid Build Coastguard Worker 1324*0e209d39SAndroid Build Coastguard Worker /** 1325*0e209d39SAndroid Build Coastguard Worker * Convert a UTF-16 string to UTF-32. 1326*0e209d39SAndroid Build Coastguard Worker * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set. 1327*0e209d39SAndroid Build Coastguard Worker * 1328*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be zero-terminated if 1329*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 1330*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of UChar32s). If it is 0, then 1331*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the 1332*0e209d39SAndroid Build Coastguard Worker * result without writing any of the result string (pre-flighting). 1333*0e209d39SAndroid Build Coastguard Worker * @param pDestLength A pointer to receive the number of units written to the destination. If 1334*0e209d39SAndroid Build Coastguard Worker * pDestLength!=NULL then *pDestLength is always set to the 1335*0e209d39SAndroid Build Coastguard Worker * number of output units corresponding to the transformation of 1336*0e209d39SAndroid Build Coastguard Worker * all the input units, even in case of a buffer overflow. 1337*0e209d39SAndroid Build Coastguard Worker * @param src The original source string 1338*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be zero-terminated. 1339*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 1340*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 1341*0e209d39SAndroid Build Coastguard Worker * @return The pointer to destination buffer. 1342*0e209d39SAndroid Build Coastguard Worker * @see u_strToUTF32WithSub 1343*0e209d39SAndroid Build Coastguard Worker * @see u_strFromUTF32 1344*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 1345*0e209d39SAndroid Build Coastguard Worker */ 1346*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar32* U_EXPORT2 1347*0e209d39SAndroid Build Coastguard Worker u_strToUTF32(UChar32 *dest, 1348*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 1349*0e209d39SAndroid Build Coastguard Worker int32_t *pDestLength, 1350*0e209d39SAndroid Build Coastguard Worker const UChar *src, 1351*0e209d39SAndroid Build Coastguard Worker int32_t srcLength, 1352*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(31); 1353*0e209d39SAndroid Build Coastguard Worker 1354*0e209d39SAndroid Build Coastguard Worker 1355*0e209d39SAndroid Build Coastguard Worker 1356*0e209d39SAndroid Build Coastguard Worker /** 1357*0e209d39SAndroid Build Coastguard Worker * Convert a UTF-32 string to UTF-16. 1358*0e209d39SAndroid Build Coastguard Worker * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set. 1359*0e209d39SAndroid Build Coastguard Worker * 1360*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be zero-terminated if 1361*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 1362*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of UChars). If it is 0, then 1363*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the 1364*0e209d39SAndroid Build Coastguard Worker * result without writing any of the result string (pre-flighting). 1365*0e209d39SAndroid Build Coastguard Worker * @param pDestLength A pointer to receive the number of units written to the destination. If 1366*0e209d39SAndroid Build Coastguard Worker * pDestLength!=NULL then *pDestLength is always set to the 1367*0e209d39SAndroid Build Coastguard Worker * number of output units corresponding to the transformation of 1368*0e209d39SAndroid Build Coastguard Worker * all the input units, even in case of a buffer overflow. 1369*0e209d39SAndroid Build Coastguard Worker * @param src The original source string 1370*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be zero-terminated. 1371*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 1372*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 1373*0e209d39SAndroid Build Coastguard Worker * @return The pointer to destination buffer. 1374*0e209d39SAndroid Build Coastguard Worker * @see u_strFromUTF32WithSub 1375*0e209d39SAndroid Build Coastguard Worker * @see u_strToUTF32 1376*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 1377*0e209d39SAndroid Build Coastguard Worker */ 1378*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar* U_EXPORT2 1379*0e209d39SAndroid Build Coastguard Worker u_strFromUTF32(UChar *dest, 1380*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 1381*0e209d39SAndroid Build Coastguard Worker int32_t *pDestLength, 1382*0e209d39SAndroid Build Coastguard Worker const UChar32 *src, 1383*0e209d39SAndroid Build Coastguard Worker int32_t srcLength, 1384*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(31); 1385*0e209d39SAndroid Build Coastguard Worker 1386*0e209d39SAndroid Build Coastguard Worker 1387*0e209d39SAndroid Build Coastguard Worker 1388*0e209d39SAndroid Build Coastguard Worker /** 1389*0e209d39SAndroid Build Coastguard Worker * Convert a UTF-16 string to UTF-32. 1390*0e209d39SAndroid Build Coastguard Worker * 1391*0e209d39SAndroid Build Coastguard Worker * Same as u_strToUTF32() except for the additional subchar which is output for 1392*0e209d39SAndroid Build Coastguard Worker * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code. 1393*0e209d39SAndroid Build Coastguard Worker * With subchar==U_SENTINEL, this function behaves exactly like u_strToUTF32(). 1394*0e209d39SAndroid Build Coastguard Worker * 1395*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be zero-terminated if 1396*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 1397*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of UChar32s). If it is 0, then 1398*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the 1399*0e209d39SAndroid Build Coastguard Worker * result without writing any of the result string (pre-flighting). 1400*0e209d39SAndroid Build Coastguard Worker * @param pDestLength A pointer to receive the number of units written to the destination. If 1401*0e209d39SAndroid Build Coastguard Worker * pDestLength!=NULL then *pDestLength is always set to the 1402*0e209d39SAndroid Build Coastguard Worker * number of output units corresponding to the transformation of 1403*0e209d39SAndroid Build Coastguard Worker * all the input units, even in case of a buffer overflow. 1404*0e209d39SAndroid Build Coastguard Worker * @param src The original source string 1405*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be zero-terminated. 1406*0e209d39SAndroid Build Coastguard Worker * @param subchar The substitution character to use in place of an illegal input sequence, 1407*0e209d39SAndroid Build Coastguard Worker * or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead. 1408*0e209d39SAndroid Build Coastguard Worker * A substitution character can be any valid Unicode code point (up to U+10FFFF) 1409*0e209d39SAndroid Build Coastguard Worker * except for surrogate code points (U+D800..U+DFFF). 1410*0e209d39SAndroid Build Coastguard Worker * The recommended value is U+FFFD "REPLACEMENT CHARACTER". 1411*0e209d39SAndroid Build Coastguard Worker * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0. 1412*0e209d39SAndroid Build Coastguard Worker * Set to 0 if no substitutions occur or subchar<0. 1413*0e209d39SAndroid Build Coastguard Worker * pNumSubstitutions can be NULL. 1414*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Pointer to a standard ICU error code. Its input value must 1415*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns 1416*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with 1417*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.) 1418*0e209d39SAndroid Build Coastguard Worker * @return The pointer to destination buffer. 1419*0e209d39SAndroid Build Coastguard Worker * @see u_strToUTF32 1420*0e209d39SAndroid Build Coastguard Worker * @see u_strFromUTF32WithSub 1421*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.2 1422*0e209d39SAndroid Build Coastguard Worker */ 1423*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar32* U_EXPORT2 1424*0e209d39SAndroid Build Coastguard Worker u_strToUTF32WithSub(UChar32 *dest, 1425*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 1426*0e209d39SAndroid Build Coastguard Worker int32_t *pDestLength, 1427*0e209d39SAndroid Build Coastguard Worker const UChar *src, 1428*0e209d39SAndroid Build Coastguard Worker int32_t srcLength, 1429*0e209d39SAndroid Build Coastguard Worker UChar32 subchar, int32_t *pNumSubstitutions, 1430*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(31); 1431*0e209d39SAndroid Build Coastguard Worker 1432*0e209d39SAndroid Build Coastguard Worker 1433*0e209d39SAndroid Build Coastguard Worker 1434*0e209d39SAndroid Build Coastguard Worker /** 1435*0e209d39SAndroid Build Coastguard Worker * Convert a UTF-32 string to UTF-16. 1436*0e209d39SAndroid Build Coastguard Worker * 1437*0e209d39SAndroid Build Coastguard Worker * Same as u_strFromUTF32() except for the additional subchar which is output for 1438*0e209d39SAndroid Build Coastguard Worker * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code. 1439*0e209d39SAndroid Build Coastguard Worker * With subchar==U_SENTINEL, this function behaves exactly like u_strFromUTF32(). 1440*0e209d39SAndroid Build Coastguard Worker * 1441*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be zero-terminated if 1442*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 1443*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of UChars). If it is 0, then 1444*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the 1445*0e209d39SAndroid Build Coastguard Worker * result without writing any of the result string (pre-flighting). 1446*0e209d39SAndroid Build Coastguard Worker * @param pDestLength A pointer to receive the number of units written to the destination. If 1447*0e209d39SAndroid Build Coastguard Worker * pDestLength!=NULL then *pDestLength is always set to the 1448*0e209d39SAndroid Build Coastguard Worker * number of output units corresponding to the transformation of 1449*0e209d39SAndroid Build Coastguard Worker * all the input units, even in case of a buffer overflow. 1450*0e209d39SAndroid Build Coastguard Worker * @param src The original source string 1451*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be zero-terminated. 1452*0e209d39SAndroid Build Coastguard Worker * @param subchar The substitution character to use in place of an illegal input sequence, 1453*0e209d39SAndroid Build Coastguard Worker * or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead. 1454*0e209d39SAndroid Build Coastguard Worker * A substitution character can be any valid Unicode code point (up to U+10FFFF) 1455*0e209d39SAndroid Build Coastguard Worker * except for surrogate code points (U+D800..U+DFFF). 1456*0e209d39SAndroid Build Coastguard Worker * The recommended value is U+FFFD "REPLACEMENT CHARACTER". 1457*0e209d39SAndroid Build Coastguard Worker * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0. 1458*0e209d39SAndroid Build Coastguard Worker * Set to 0 if no substitutions occur or subchar<0. 1459*0e209d39SAndroid Build Coastguard Worker * pNumSubstitutions can be NULL. 1460*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Pointer to a standard ICU error code. Its input value must 1461*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns 1462*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with 1463*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.) 1464*0e209d39SAndroid Build Coastguard Worker * @return The pointer to destination buffer. 1465*0e209d39SAndroid Build Coastguard Worker * @see u_strFromUTF32 1466*0e209d39SAndroid Build Coastguard Worker * @see u_strToUTF32WithSub 1467*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.2 1468*0e209d39SAndroid Build Coastguard Worker */ 1469*0e209d39SAndroid Build Coastguard Worker U_CAPI UChar* U_EXPORT2 1470*0e209d39SAndroid Build Coastguard Worker u_strFromUTF32WithSub(UChar *dest, 1471*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 1472*0e209d39SAndroid Build Coastguard Worker int32_t *pDestLength, 1473*0e209d39SAndroid Build Coastguard Worker const UChar32 *src, 1474*0e209d39SAndroid Build Coastguard Worker int32_t srcLength, 1475*0e209d39SAndroid Build Coastguard Worker UChar32 subchar, int32_t *pNumSubstitutions, 1476*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(31); 1477*0e209d39SAndroid Build Coastguard Worker 1478*0e209d39SAndroid Build Coastguard Worker 1479*0e209d39SAndroid Build Coastguard Worker 1480*0e209d39SAndroid Build Coastguard Worker 1481*0e209d39SAndroid Build Coastguard Worker 1482*0e209d39SAndroid Build Coastguard Worker 1483*0e209d39SAndroid Build Coastguard Worker 1484*0e209d39SAndroid Build Coastguard Worker #endif 1485*0e209d39SAndroid Build Coastguard Worker 1486*0e209d39SAndroid Build Coastguard Worker /** @} */ // addtogroup 1487