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