Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/unicode/ustring.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // © 2016 and later: Unicode, Inc. and others.
0002 // License & terms of use: http://www.unicode.org/copyright.html
0003 /*
0004 **********************************************************************
0005 *   Copyright (C) 1998-2014, International Business Machines
0006 *   Corporation and others.  All Rights Reserved.
0007 **********************************************************************
0008 *
0009 * File ustring.h
0010 *
0011 * Modification History:
0012 *
0013 *   Date        Name        Description
0014 *   12/07/98    bertrand    Creation.
0015 ******************************************************************************
0016 */
0017 
0018 #ifndef USTRING_H
0019 #define USTRING_H
0020 
0021 #include "unicode/utypes.h"
0022 #include "unicode/putil.h"
0023 #include "unicode/uiter.h"
0024 
0025 /**
0026  * \def UBRK_TYPEDEF_UBREAK_ITERATOR
0027  * @internal 
0028  */
0029 
0030 #ifndef UBRK_TYPEDEF_UBREAK_ITERATOR
0031 #   define UBRK_TYPEDEF_UBREAK_ITERATOR
0032 /** Simple declaration for u_strToTitle() to avoid including unicode/ubrk.h. @stable ICU 2.1*/
0033     typedef struct UBreakIterator UBreakIterator;
0034 #endif
0035 
0036 /**
0037  * \file
0038  * \brief C API: Unicode string handling functions
0039  *
0040  * These C API functions provide general Unicode string handling.
0041  *
0042  * Some functions are equivalent in name, signature, and behavior to the ANSI C <string.h>
0043  * functions. (For example, they do not check for bad arguments like NULL string pointers.)
0044  * In some cases, only the thread-safe variant of such a function is implemented here
0045  * (see u_strtok_r()).
0046  *
0047  * Other functions provide more Unicode-specific functionality like locale-specific
0048  * upper/lower-casing and string comparison in code point order.
0049  *
0050  * ICU uses 16-bit Unicode (UTF-16) in the form of arrays of UChar code units.
0051  * UTF-16 encodes each Unicode code point with either one or two UChar code units.
0052  * (This is the default form of Unicode, and a forward-compatible extension of the original,
0053  * fixed-width form that was known as UCS-2. UTF-16 superseded UCS-2 with Unicode 2.0
0054  * in 1996.)
0055  *
0056  * Some APIs accept a 32-bit UChar32 value for a single code point.
0057  *
0058  * ICU also handles 16-bit Unicode text with unpaired surrogates.
0059  * Such text is not well-formed UTF-16.
0060  * Code-point-related functions treat unpaired surrogates as surrogate code points,
0061  * i.e., as separate units.
0062  *
0063  * Although UTF-16 is a variable-width encoding form (like some legacy multi-byte encodings),
0064  * it is much more efficient even for random access because the code unit values
0065  * for single-unit characters vs. lead units vs. trail units are completely disjoint.
0066  * This means that it is easy to determine character (code point) boundaries from
0067  * random offsets in the string.
0068  *
0069  * Unicode (UTF-16) string processing is optimized for the single-unit case.
0070  * Although it is important to support supplementary characters
0071  * (which use pairs of lead/trail code units called "surrogates"),
0072  * their occurrence is rare. Almost all characters in modern use require only
0073  * a single UChar code unit (i.e., their code point values are <=0xffff).
0074  *
0075  * For more details see the User Guide Strings chapter (https://unicode-org.github.io/icu/userguide/strings/).
0076  * For a discussion of the handling of unpaired surrogates see also
0077  * Jitterbug 2145 and its icu mailing list proposal on 2002-sep-18.
0078  */
0079 
0080 /**
0081  * \defgroup ustring_ustrlen String Length
0082  * \ingroup ustring_strlen
0083  */
0084 /*@{*/
0085 /**
0086  * Determine the length of an array of UChar.
0087  *
0088  * @param s The array of UChars, NULL (U+0000) terminated.
0089  * @return The number of UChars in <code>chars</code>, minus the terminator.
0090  * @stable ICU 2.0
0091  */
0092 U_CAPI int32_t U_EXPORT2
0093 u_strlen(const UChar *s);
0094 /*@}*/
0095 
0096 /**
0097  * Count Unicode code points in the length UChar code units of the string.
0098  * A code point may occupy either one or two UChar code units.
0099  * Counting code points involves reading all code units.
0100  *
0101  * This functions is basically the inverse of the U16_FWD_N() macro (see utf.h).
0102  *
0103  * @param s The input string.
0104  * @param length The number of UChar code units to be checked, or -1 to count all
0105  *               code points before the first NUL (U+0000).
0106  * @return The number of code points in the specified code units.
0107  * @stable ICU 2.0
0108  */
0109 U_CAPI int32_t U_EXPORT2
0110 u_countChar32(const UChar *s, int32_t length);
0111 
0112 /**
0113  * Check if the string contains more Unicode code points than a certain number.
0114  * This is more efficient than counting all code points in the entire string
0115  * and comparing that number with a threshold.
0116  * This function may not need to scan the string at all if the length is known
0117  * (not -1 for NUL-termination) and falls within a certain range, and
0118  * never needs to count more than 'number+1' code points.
0119  * Logically equivalent to (u_countChar32(s, length)>number).
0120  * A Unicode code point may occupy either one or two UChar code units.
0121  *
0122  * @param s The input string.
0123  * @param length The length of the string, or -1 if it is NUL-terminated.
0124  * @param number The number of code points in the string is compared against
0125  *               the 'number' parameter.
0126  * @return Boolean value for whether the string contains more Unicode code points
0127  *         than 'number'. Same as (u_countChar32(s, length)>number).
0128  * @stable ICU 2.4
0129  */
0130 U_CAPI UBool U_EXPORT2
0131 u_strHasMoreChar32Than(const UChar *s, int32_t length, int32_t number);
0132 
0133 /**
0134  * Concatenate two ustrings.  Appends a copy of <code>src</code>,
0135  * including the null terminator, to <code>dst</code>. The initial copied
0136  * character from <code>src</code> overwrites the null terminator in <code>dst</code>.
0137  *
0138  * @param dst The destination string.
0139  * @param src The source string.
0140  * @return A pointer to <code>dst</code>.
0141  * @stable ICU 2.0
0142  */
0143 U_CAPI UChar* U_EXPORT2
0144 u_strcat(UChar     *dst, 
0145     const UChar     *src);
0146 
0147 /**
0148  * Concatenate two ustrings.  
0149  * Appends at most <code>n</code> characters from <code>src</code> to <code>dst</code>.
0150  * Adds a terminating NUL.
0151  * If src is too long, then only <code>n-1</code> characters will be copied
0152  * before the terminating NUL.
0153  * If <code>n&lt;=0</code> then dst is not modified.
0154  *
0155  * @param dst The destination string.
0156  * @param src The source string (can be NULL/invalid if n<=0).
0157  * @param n The maximum number of characters to append; no-op if <=0.
0158  * @return A pointer to <code>dst</code>.
0159  * @stable ICU 2.0
0160  */
0161 U_CAPI UChar* U_EXPORT2
0162 u_strncat(UChar     *dst, 
0163      const UChar     *src, 
0164      int32_t     n);
0165 
0166 /**
0167  * Find the first occurrence of a substring in a string.
0168  * The substring is found at code point boundaries.
0169  * That means that if the substring begins with
0170  * a trail surrogate or ends with a lead surrogate,
0171  * then it is found only if these surrogates stand alone in the text.
0172  * Otherwise, the substring edge units would be matched against
0173  * halves of surrogate pairs.
0174  *
0175  * @param s The string to search (NUL-terminated).
0176  * @param substring The substring to find (NUL-terminated).
0177  * @return A pointer to the first occurrence of <code>substring</code> in <code>s</code>,
0178  *         or <code>s</code> itself if the <code>substring</code> is empty,
0179  *         or <code>NULL</code> if <code>substring</code> is not in <code>s</code>.
0180  * @stable ICU 2.0
0181  *
0182  * @see u_strrstr
0183  * @see u_strFindFirst
0184  * @see u_strFindLast
0185  */
0186 U_CAPI UChar * U_EXPORT2
0187 u_strstr(const UChar *s, const UChar *substring);
0188 
0189 /**
0190  * Find the first occurrence of a substring in a string.
0191  * The substring is found at code point boundaries.
0192  * That means that if the substring begins with
0193  * a trail surrogate or ends with a lead surrogate,
0194  * then it is found only if these surrogates stand alone in the text.
0195  * Otherwise, the substring edge units would be matched against
0196  * halves of surrogate pairs.
0197  *
0198  * @param s The string to search.
0199  * @param length The length of s (number of UChars), or -1 if it is NUL-terminated.
0200  * @param substring The substring to find (NUL-terminated).
0201  * @param subLength The length of substring (number of UChars), or -1 if it is NUL-terminated.
0202  * @return A pointer to the first occurrence of <code>substring</code> in <code>s</code>,
0203  *         or <code>s</code> itself if the <code>substring</code> is empty,
0204  *         or <code>NULL</code> if <code>substring</code> is not in <code>s</code>.
0205  * @stable ICU 2.4
0206  *
0207  * @see u_strstr
0208  * @see u_strFindLast
0209  */
0210 U_CAPI UChar * U_EXPORT2
0211 u_strFindFirst(const UChar *s, int32_t length, const UChar *substring, int32_t subLength);
0212 
0213 /**
0214  * Find the first occurrence of a BMP code point in a string.
0215  * A surrogate code point is found only if its match in the text is not
0216  * part of a surrogate pair.
0217  * A NUL character is found at the string terminator.
0218  *
0219  * @param s The string to search (NUL-terminated).
0220  * @param c The BMP code point to find.
0221  * @return A pointer to the first occurrence of <code>c</code> in <code>s</code>
0222  *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.
0223  * @stable ICU 2.0
0224  *
0225  * @see u_strchr32
0226  * @see u_memchr
0227  * @see u_strstr
0228  * @see u_strFindFirst
0229  */
0230 U_CAPI UChar * U_EXPORT2
0231 u_strchr(const UChar *s, UChar c);
0232 
0233 /**
0234  * Find the first occurrence of a code point in a string.
0235  * A surrogate code point is found only if its match in the text is not
0236  * part of a surrogate pair.
0237  * A NUL character is found at the string terminator.
0238  *
0239  * @param s The string to search (NUL-terminated).
0240  * @param c The code point to find.
0241  * @return A pointer to the first occurrence of <code>c</code> in <code>s</code>
0242  *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.
0243  * @stable ICU 2.0
0244  *
0245  * @see u_strchr
0246  * @see u_memchr32
0247  * @see u_strstr
0248  * @see u_strFindFirst
0249  */
0250 U_CAPI UChar * U_EXPORT2
0251 u_strchr32(const UChar *s, UChar32 c);
0252 
0253 /**
0254  * Find the last occurrence of a substring in a string.
0255  * The substring is found at code point boundaries.
0256  * That means that if the substring begins with
0257  * a trail surrogate or ends with a lead surrogate,
0258  * then it is found only if these surrogates stand alone in the text.
0259  * Otherwise, the substring edge units would be matched against
0260  * halves of surrogate pairs.
0261  *
0262  * @param s The string to search (NUL-terminated).
0263  * @param substring The substring to find (NUL-terminated).
0264  * @return A pointer to the last occurrence of <code>substring</code> in <code>s</code>,
0265  *         or <code>s</code> itself if the <code>substring</code> is empty,
0266  *         or <code>NULL</code> if <code>substring</code> is not in <code>s</code>.
0267  * @stable ICU 2.4
0268  *
0269  * @see u_strstr
0270  * @see u_strFindFirst
0271  * @see u_strFindLast
0272  */
0273 U_CAPI UChar * U_EXPORT2
0274 u_strrstr(const UChar *s, const UChar *substring);
0275 
0276 /**
0277  * Find the last occurrence of a substring in a string.
0278  * The substring is found at code point boundaries.
0279  * That means that if the substring begins with
0280  * a trail surrogate or ends with a lead surrogate,
0281  * then it is found only if these surrogates stand alone in the text.
0282  * Otherwise, the substring edge units would be matched against
0283  * halves of surrogate pairs.
0284  *
0285  * @param s The string to search.
0286  * @param length The length of s (number of UChars), or -1 if it is NUL-terminated.
0287  * @param substring The substring to find (NUL-terminated).
0288  * @param subLength The length of substring (number of UChars), or -1 if it is NUL-terminated.
0289  * @return A pointer to the last occurrence of <code>substring</code> in <code>s</code>,
0290  *         or <code>s</code> itself if the <code>substring</code> is empty,
0291  *         or <code>NULL</code> if <code>substring</code> is not in <code>s</code>.
0292  * @stable ICU 2.4
0293  *
0294  * @see u_strstr
0295  * @see u_strFindLast
0296  */
0297 U_CAPI UChar * U_EXPORT2
0298 u_strFindLast(const UChar *s, int32_t length, const UChar *substring, int32_t subLength);
0299 
0300 /**
0301  * Find the last occurrence of a BMP code point in a string.
0302  * A surrogate code point is found only if its match in the text is not
0303  * part of a surrogate pair.
0304  * A NUL character is found at the string terminator.
0305  *
0306  * @param s The string to search (NUL-terminated).
0307  * @param c The BMP code point to find.
0308  * @return A pointer to the last occurrence of <code>c</code> in <code>s</code>
0309  *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.
0310  * @stable ICU 2.4
0311  *
0312  * @see u_strrchr32
0313  * @see u_memrchr
0314  * @see u_strrstr
0315  * @see u_strFindLast
0316  */
0317 U_CAPI UChar * U_EXPORT2
0318 u_strrchr(const UChar *s, UChar c);
0319 
0320 /**
0321  * Find the last occurrence of a code point in a string.
0322  * A surrogate code point is found only if its match in the text is not
0323  * part of a surrogate pair.
0324  * A NUL character is found at the string terminator.
0325  *
0326  * @param s The string to search (NUL-terminated).
0327  * @param c The code point to find.
0328  * @return A pointer to the last occurrence of <code>c</code> in <code>s</code>
0329  *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.
0330  * @stable ICU 2.4
0331  *
0332  * @see u_strrchr
0333  * @see u_memchr32
0334  * @see u_strrstr
0335  * @see u_strFindLast
0336  */
0337 U_CAPI UChar * U_EXPORT2
0338 u_strrchr32(const UChar *s, UChar32 c);
0339 
0340 /**
0341  * Locates the first occurrence in the string <code>string</code> of any of the characters
0342  * in the string <code>matchSet</code>.
0343  * Works just like C's strpbrk but with Unicode.
0344  *
0345  * @param string The string in which to search, NUL-terminated.
0346  * @param matchSet A NUL-terminated string defining a set of code points
0347  *                 for which to search in the text string.
0348  * @return A pointer to the  character in <code>string</code> that matches one of the
0349  *         characters in <code>matchSet</code>, or NULL if no such character is found.
0350  * @stable ICU 2.0
0351  */
0352 U_CAPI UChar * U_EXPORT2
0353 u_strpbrk(const UChar *string, const UChar *matchSet);
0354 
0355 /**
0356  * Returns the number of consecutive characters in <code>string</code>,
0357  * beginning with the first, that do not occur somewhere in <code>matchSet</code>.
0358  * Works just like C's strcspn but with Unicode.
0359  *
0360  * @param string The string in which to search, NUL-terminated.
0361  * @param matchSet A NUL-terminated string defining a set of code points
0362  *                 for which to search in the text string.
0363  * @return The number of initial characters in <code>string</code> that do not
0364  *         occur in <code>matchSet</code>.
0365  * @see u_strspn
0366  * @stable ICU 2.0
0367  */
0368 U_CAPI int32_t U_EXPORT2
0369 u_strcspn(const UChar *string, const UChar *matchSet);
0370 
0371 /**
0372  * Returns the number of consecutive characters in <code>string</code>,
0373  * beginning with the first, that occur somewhere in <code>matchSet</code>.
0374  * Works just like C's strspn but with Unicode.
0375  *
0376  * @param string The string in which to search, NUL-terminated.
0377  * @param matchSet A NUL-terminated string defining a set of code points
0378  *                 for which to search in the text string.
0379  * @return The number of initial characters in <code>string</code> that do
0380  *         occur in <code>matchSet</code>.
0381  * @see u_strcspn
0382  * @stable ICU 2.0
0383  */
0384 U_CAPI int32_t U_EXPORT2
0385 u_strspn(const UChar *string, const UChar *matchSet);
0386 
0387 /**
0388  * The string tokenizer API allows an application to break a string into
0389  * tokens. Unlike strtok(), the saveState (the current pointer within the
0390  * original string) is maintained in saveState. In the first call, the
0391  * argument src is a pointer to the string. In subsequent calls to
0392  * return successive tokens of that string, src must be specified as
0393  * NULL. The value saveState is set by this function to maintain the
0394  * function's position within the string, and on each subsequent call
0395  * you must give this argument the same variable. This function does
0396  * handle surrogate pairs. This function is similar to the strtok_r()
0397  * the POSIX Threads Extension (1003.1c-1995) version.
0398  *
0399  * @param src String containing token(s). This string will be modified.
0400  *            After the first call to u_strtok_r(), this argument must
0401  *            be NULL to get to the next token.
0402  * @param delim Set of delimiter characters (Unicode code points).
0403  * @param saveState The current pointer within the original string,
0404  *              which is set by this function. The saveState
0405  *              parameter should the address of a local variable of type
0406  *              UChar *. (i.e. defined "UChar *myLocalSaveState" and use
0407  *              &myLocalSaveState for this parameter).
0408  * @return A pointer to the next token found in src, or NULL
0409  *         when there are no more tokens.
0410  * @stable ICU 2.0
0411  */
0412 U_CAPI UChar * U_EXPORT2
0413 u_strtok_r(UChar    *src, 
0414      const UChar    *delim,
0415            UChar   **saveState);
0416 
0417 /**
0418  * Compare two Unicode strings for bitwise equality (code unit order).
0419  *
0420  * @param s1 A string to compare.
0421  * @param s2 A string to compare.
0422  * @return 0 if <code>s1</code> and <code>s2</code> are bitwise equal; a negative
0423  * value if <code>s1</code> is bitwise less than <code>s2,</code>; a positive
0424  * value if <code>s1</code> is bitwise greater than <code>s2</code>.
0425  * @stable ICU 2.0
0426  */
0427 U_CAPI int32_t  U_EXPORT2
0428 u_strcmp(const UChar     *s1, 
0429          const UChar     *s2);
0430 
0431 /**
0432  * Compare two Unicode strings in code point order.
0433  * See u_strCompare for details.
0434  *
0435  * @param s1 A string to compare.
0436  * @param s2 A string to compare.
0437  * @return a negative/zero/positive integer corresponding to whether
0438  * the first string is less than/equal to/greater than the second one
0439  * in code point order
0440  * @stable ICU 2.0
0441  */
0442 U_CAPI int32_t U_EXPORT2
0443 u_strcmpCodePointOrder(const UChar *s1, const UChar *s2);
0444 
0445 /**
0446  * Compare two Unicode strings (binary order).
0447  *
0448  * The comparison can be done in code unit order or in code point order.
0449  * They differ only in UTF-16 when
0450  * comparing supplementary code points (U+10000..U+10ffff)
0451  * to BMP code points near the end of the BMP (i.e., U+e000..U+ffff).
0452  * In code unit order, high BMP code points sort after supplementary code points
0453  * because they are stored as pairs of surrogates which are at U+d800..U+dfff.
0454  *
0455  * This functions works with strings of different explicitly specified lengths
0456  * unlike the ANSI C-like u_strcmp() and u_memcmp() etc.
0457  * NUL-terminated strings are possible with length arguments of -1.
0458  *
0459  * @param s1 First source string.
0460  * @param length1 Length of first source string, or -1 if NUL-terminated.
0461  *
0462  * @param s2 Second source string.
0463  * @param length2 Length of second source string, or -1 if NUL-terminated.
0464  *
0465  * @param codePointOrder Choose between code unit order (false)
0466  *                       and code point order (true).
0467  *
0468  * @return <0 or 0 or >0 as usual for string comparisons
0469  *
0470  * @stable ICU 2.2
0471  */
0472 U_CAPI int32_t U_EXPORT2
0473 u_strCompare(const UChar *s1, int32_t length1,
0474              const UChar *s2, int32_t length2,
0475              UBool codePointOrder);
0476 
0477 /**
0478  * Compare two Unicode strings (binary order)
0479  * as presented by UCharIterator objects.
0480  * Works otherwise just like u_strCompare().
0481  *
0482  * Both iterators are reset to their start positions.
0483  * When the function returns, it is undefined where the iterators
0484  * have stopped.
0485  *
0486  * @param iter1 First source string iterator.
0487  * @param iter2 Second source string iterator.
0488  * @param codePointOrder Choose between code unit order (false)
0489  *                       and code point order (true).
0490  *
0491  * @return <0 or 0 or >0 as usual for string comparisons
0492  *
0493  * @see u_strCompare
0494  *
0495  * @stable ICU 2.6
0496  */
0497 U_CAPI int32_t U_EXPORT2
0498 u_strCompareIter(UCharIterator *iter1, UCharIterator *iter2, UBool codePointOrder);
0499 
0500 /**
0501  * Compare two strings case-insensitively using full case folding.
0502  * This is equivalent to
0503  *   u_strCompare(u_strFoldCase(s1, options),
0504  *                u_strFoldCase(s2, options),
0505  *                (options&U_COMPARE_CODE_POINT_ORDER)!=0).
0506  *
0507  * The comparison can be done in UTF-16 code unit order or in code point order.
0508  * They differ only when comparing supplementary code points (U+10000..U+10ffff)
0509  * to BMP code points near the end of the BMP (i.e., U+e000..U+ffff).
0510  * In code unit order, high BMP code points sort after supplementary code points
0511  * because they are stored as pairs of surrogates which are at U+d800..U+dfff.
0512  *
0513  * This functions works with strings of different explicitly specified lengths
0514  * unlike the ANSI C-like u_strcmp() and u_memcmp() etc.
0515  * NUL-terminated strings are possible with length arguments of -1.
0516  *
0517  * @param s1 First source string.
0518  * @param length1 Length of first source string, or -1 if NUL-terminated.
0519  *
0520  * @param s2 Second source string.
0521  * @param length2 Length of second source string, or -1 if NUL-terminated.
0522  *
0523  * @param options A bit set of options:
0524  *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
0525  *     Comparison in code unit order with default case folding.
0526  *
0527  *   - U_COMPARE_CODE_POINT_ORDER
0528  *     Set to choose code point order instead of code unit order
0529  *     (see u_strCompare for details).
0530  *
0531  *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
0532  *
0533  * @param pErrorCode Must be a valid pointer to an error code value,
0534  *                  which must not indicate a failure before the function call.
0535  *
0536  * @return <0 or 0 or >0 as usual for string comparisons
0537  *
0538  * @stable ICU 2.2
0539  */
0540 U_CAPI int32_t U_EXPORT2
0541 u_strCaseCompare(const UChar *s1, int32_t length1,
0542                  const UChar *s2, int32_t length2,
0543                  uint32_t options,
0544                  UErrorCode *pErrorCode);
0545 
0546 /**
0547  * Compare two ustrings for bitwise equality. 
0548  * Compares at most <code>n</code> characters.
0549  *
0550  * @param ucs1 A string to compare (can be NULL/invalid if n<=0).
0551  * @param ucs2 A string to compare (can be NULL/invalid if n<=0).
0552  * @param n The maximum number of characters to compare; always returns 0 if n<=0.
0553  * @return 0 if <code>s1</code> and <code>s2</code> are bitwise equal; a negative
0554  * value if <code>s1</code> is bitwise less than <code>s2</code>; a positive
0555  * value if <code>s1</code> is bitwise greater than <code>s2</code>.
0556  * @stable ICU 2.0
0557  */
0558 U_CAPI int32_t U_EXPORT2
0559 u_strncmp(const UChar     *ucs1, 
0560      const UChar     *ucs2, 
0561      int32_t     n);
0562 
0563 /**
0564  * Compare two Unicode strings in code point order.
0565  * This is different in UTF-16 from u_strncmp() if supplementary characters are present.
0566  * For details, see u_strCompare().
0567  *
0568  * @param s1 A string to compare.
0569  * @param s2 A string to compare.
0570  * @param n The maximum number of characters to compare.
0571  * @return a negative/zero/positive integer corresponding to whether
0572  * the first string is less than/equal to/greater than the second one
0573  * in code point order
0574  * @stable ICU 2.0
0575  */
0576 U_CAPI int32_t U_EXPORT2
0577 u_strncmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t n);
0578 
0579 /**
0580  * Compare two strings case-insensitively using full case folding.
0581  * This is equivalent to u_strcmp(u_strFoldCase(s1, options), u_strFoldCase(s2, options)).
0582  *
0583  * @param s1 A string to compare.
0584  * @param s2 A string to compare.
0585  * @param options A bit set of options:
0586  *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
0587  *     Comparison in code unit order with default case folding.
0588  *
0589  *   - U_COMPARE_CODE_POINT_ORDER
0590  *     Set to choose code point order instead of code unit order
0591  *     (see u_strCompare for details).
0592  *
0593  *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
0594  *
0595  * @return A negative, zero, or positive integer indicating the comparison result.
0596  * @stable ICU 2.0
0597  */
0598 U_CAPI int32_t U_EXPORT2
0599 u_strcasecmp(const UChar *s1, const UChar *s2, uint32_t options);
0600 
0601 /**
0602  * Compare two strings case-insensitively using full case folding.
0603  * This is equivalent to u_strcmp(u_strFoldCase(s1, at most n, options),
0604  * u_strFoldCase(s2, at most n, options)).
0605  *
0606  * @param s1 A string to compare.
0607  * @param s2 A string to compare.
0608  * @param n The maximum number of characters each string to case-fold and then compare.
0609  * @param options A bit set of options:
0610  *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
0611  *     Comparison in code unit order with default case folding.
0612  *
0613  *   - U_COMPARE_CODE_POINT_ORDER
0614  *     Set to choose code point order instead of code unit order
0615  *     (see u_strCompare for details).
0616  *
0617  *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
0618  *
0619  * @return A negative, zero, or positive integer indicating the comparison result.
0620  * @stable ICU 2.0
0621  */
0622 U_CAPI int32_t U_EXPORT2
0623 u_strncasecmp(const UChar *s1, const UChar *s2, int32_t n, uint32_t options);
0624 
0625 /**
0626  * Compare two strings case-insensitively using full case folding.
0627  * This is equivalent to u_strcmp(u_strFoldCase(s1, n, options),
0628  * u_strFoldCase(s2, n, options)).
0629  *
0630  * @param s1 A string to compare.
0631  * @param s2 A string to compare.
0632  * @param length The number of characters in each string to case-fold and then compare.
0633  * @param options A bit set of options:
0634  *   - U_FOLD_CASE_DEFAULT or 0 is used for default options:
0635  *     Comparison in code unit order with default case folding.
0636  *
0637  *   - U_COMPARE_CODE_POINT_ORDER
0638  *     Set to choose code point order instead of code unit order
0639  *     (see u_strCompare for details).
0640  *
0641  *   - U_FOLD_CASE_EXCLUDE_SPECIAL_I
0642  *
0643  * @return A negative, zero, or positive integer indicating the comparison result.
0644  * @stable ICU 2.0
0645  */
0646 U_CAPI int32_t U_EXPORT2
0647 u_memcasecmp(const UChar *s1, const UChar *s2, int32_t length, uint32_t options);
0648 
0649 /**
0650  * Copy a ustring. Adds a null terminator.
0651  *
0652  * @param dst The destination string.
0653  * @param src The source string.
0654  * @return A pointer to <code>dst</code>.
0655  * @stable ICU 2.0
0656  */
0657 U_CAPI UChar* U_EXPORT2
0658 u_strcpy(UChar     *dst, 
0659     const UChar     *src);
0660 
0661 /**
0662  * Copy a ustring.
0663  * Copies at most <code>n</code> characters.  The result will be null terminated
0664  * if the length of <code>src</code> is less than <code>n</code>.
0665  *
0666  * @param dst The destination string.
0667  * @param src The source string (can be NULL/invalid if n<=0).
0668  * @param n The maximum number of characters to copy; no-op if <=0.
0669  * @return A pointer to <code>dst</code>.
0670  * @stable ICU 2.0
0671  */
0672 U_CAPI UChar* U_EXPORT2
0673 u_strncpy(UChar     *dst, 
0674      const UChar     *src, 
0675      int32_t     n);
0676 
0677 #if !UCONFIG_NO_CONVERSION
0678 
0679 /**
0680  * Copy a byte string encoded in the default codepage to a ustring.
0681  * Adds a null terminator.
0682  * Performs a host byte to UChar conversion
0683  *
0684  * @param dst The destination string.
0685  * @param src The source string.
0686  * @return A pointer to <code>dst</code>.
0687  * @stable ICU 2.0
0688  */
0689 U_CAPI UChar* U_EXPORT2 u_uastrcpy(UChar *dst,
0690                const char *src );
0691 
0692 /**
0693  * Copy a byte string encoded in the default codepage to a ustring.
0694  * Copies at most <code>n</code> characters.  The result will be null terminated
0695  * if the length of <code>src</code> is less than <code>n</code>.
0696  * Performs a host byte to UChar conversion
0697  *
0698  * @param dst The destination string.
0699  * @param src The source string.
0700  * @param n The maximum number of characters to copy.
0701  * @return A pointer to <code>dst</code>.
0702  * @stable ICU 2.0
0703  */
0704 U_CAPI UChar* U_EXPORT2 u_uastrncpy(UChar *dst,
0705             const char *src,
0706             int32_t n);
0707 
0708 /**
0709  * Copy ustring to a byte string encoded in the default codepage.
0710  * Adds a null terminator.
0711  * Performs a UChar to host byte conversion
0712  *
0713  * @param dst The destination string.
0714  * @param src The source string.
0715  * @return A pointer to <code>dst</code>.
0716  * @stable ICU 2.0
0717  */
0718 U_CAPI char* U_EXPORT2 u_austrcpy(char *dst,
0719             const UChar *src );
0720 
0721 /**
0722  * Copy ustring to a byte string encoded in the default codepage.
0723  * Copies at most <code>n</code> characters.  The result will be null terminated
0724  * if the length of <code>src</code> is less than <code>n</code>.
0725  * Performs a UChar to host byte conversion
0726  *
0727  * @param dst The destination string.
0728  * @param src The source string.
0729  * @param n The maximum number of characters to copy.
0730  * @return A pointer to <code>dst</code>.
0731  * @stable ICU 2.0
0732  */
0733 U_CAPI char* U_EXPORT2 u_austrncpy(char *dst,
0734             const UChar *src,
0735             int32_t n );
0736 
0737 #endif
0738 
0739 /**
0740  * Synonym for memcpy(), but with UChars only.
0741  * @param dest The destination string
0742  * @param src The source string (can be NULL/invalid if count<=0)
0743  * @param count The number of characters to copy; no-op if <=0
0744  * @return A pointer to <code>dest</code>
0745  * @stable ICU 2.0
0746  */
0747 U_CAPI UChar* U_EXPORT2
0748 u_memcpy(UChar *dest, const UChar *src, int32_t count);
0749 
0750 /**
0751  * Synonym for memmove(), but with UChars only.
0752  * @param dest The destination string
0753  * @param src The source string (can be NULL/invalid if count<=0)
0754  * @param count The number of characters to move; no-op if <=0
0755  * @return A pointer to <code>dest</code>
0756  * @stable ICU 2.0
0757  */
0758 U_CAPI UChar* U_EXPORT2
0759 u_memmove(UChar *dest, const UChar *src, int32_t count);
0760 
0761 /**
0762  * Initialize <code>count</code> characters of <code>dest</code> to <code>c</code>.
0763  *
0764  * @param dest The destination string.
0765  * @param c The character to initialize the string.
0766  * @param count The maximum number of characters to set.
0767  * @return A pointer to <code>dest</code>.
0768  * @stable ICU 2.0
0769  */
0770 U_CAPI UChar* U_EXPORT2
0771 u_memset(UChar *dest, UChar c, int32_t count);
0772 
0773 /**
0774  * Compare the first <code>count</code> UChars of each buffer.
0775  *
0776  * @param buf1 The first string to compare.
0777  * @param buf2 The second string to compare.
0778  * @param count The maximum number of UChars to compare.
0779  * @return When buf1 < buf2, a negative number is returned.
0780  *      When buf1 == buf2, 0 is returned.
0781  *      When buf1 > buf2, a positive number is returned.
0782  * @stable ICU 2.0
0783  */
0784 U_CAPI int32_t U_EXPORT2
0785 u_memcmp(const UChar *buf1, const UChar *buf2, int32_t count);
0786 
0787 /**
0788  * Compare two Unicode strings in code point order.
0789  * This is different in UTF-16 from u_memcmp() if supplementary characters are present.
0790  * For details, see u_strCompare().
0791  *
0792  * @param s1 A string to compare.
0793  * @param s2 A string to compare.
0794  * @param count The maximum number of characters to compare.
0795  * @return a negative/zero/positive integer corresponding to whether
0796  * the first string is less than/equal to/greater than the second one
0797  * in code point order
0798  * @stable ICU 2.0
0799  */
0800 U_CAPI int32_t U_EXPORT2
0801 u_memcmpCodePointOrder(const UChar *s1, const UChar *s2, int32_t count);
0802 
0803 /**
0804  * Find the first occurrence of a BMP code point in a string.
0805  * A surrogate code point is found only if its match in the text is not
0806  * part of a surrogate pair.
0807  * A NUL character is found at the string terminator.
0808  *
0809  * @param s The string to search (contains <code>count</code> UChars).
0810  * @param c The BMP code point to find.
0811  * @param count The length of the string.
0812  * @return A pointer to the first occurrence of <code>c</code> in <code>s</code>
0813  *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.
0814  * @stable ICU 2.0
0815  *
0816  * @see u_strchr
0817  * @see u_memchr32
0818  * @see u_strFindFirst
0819  */
0820 U_CAPI UChar* U_EXPORT2
0821 u_memchr(const UChar *s, UChar c, int32_t count);
0822 
0823 /**
0824  * Find the first occurrence of a code point in a string.
0825  * A surrogate code point is found only if its match in the text is not
0826  * part of a surrogate pair.
0827  * A NUL character is found at the string terminator.
0828  *
0829  * @param s The string to search (contains <code>count</code> UChars).
0830  * @param c The code point to find.
0831  * @param count The length of the string.
0832  * @return A pointer to the first occurrence of <code>c</code> in <code>s</code>
0833  *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.
0834  * @stable ICU 2.0
0835  *
0836  * @see u_strchr32
0837  * @see u_memchr
0838  * @see u_strFindFirst
0839  */
0840 U_CAPI UChar* U_EXPORT2
0841 u_memchr32(const UChar *s, UChar32 c, int32_t count);
0842 
0843 /**
0844  * Find the last occurrence of a BMP code point in a string.
0845  * A surrogate code point is found only if its match in the text is not
0846  * part of a surrogate pair.
0847  * A NUL character is found at the string terminator.
0848  *
0849  * @param s The string to search (contains <code>count</code> UChars).
0850  * @param c The BMP code point to find.
0851  * @param count The length of the string.
0852  * @return A pointer to the last occurrence of <code>c</code> in <code>s</code>
0853  *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.
0854  * @stable ICU 2.4
0855  *
0856  * @see u_strrchr
0857  * @see u_memrchr32
0858  * @see u_strFindLast
0859  */
0860 U_CAPI UChar* U_EXPORT2
0861 u_memrchr(const UChar *s, UChar c, int32_t count);
0862 
0863 /**
0864  * Find the last occurrence of a code point in a string.
0865  * A surrogate code point is found only if its match in the text is not
0866  * part of a surrogate pair.
0867  * A NUL character is found at the string terminator.
0868  *
0869  * @param s The string to search (contains <code>count</code> UChars).
0870  * @param c The code point to find.
0871  * @param count The length of the string.
0872  * @return A pointer to the last occurrence of <code>c</code> in <code>s</code>
0873  *         or <code>NULL</code> if <code>c</code> is not in <code>s</code>.
0874  * @stable ICU 2.4
0875  *
0876  * @see u_strrchr32
0877  * @see u_memrchr
0878  * @see u_strFindLast
0879  */
0880 U_CAPI UChar* U_EXPORT2
0881 u_memrchr32(const UChar *s, UChar32 c, int32_t count);
0882 
0883 /**
0884  * Unicode String literals in C.
0885  * We need one macro to declare a variable for the string
0886  * and to statically preinitialize it if possible,
0887  * and a second macro to dynamically initialize such a string variable if necessary.
0888  *
0889  * The macros are defined for maximum performance.
0890  * They work only for strings that contain "invariant characters", i.e.,
0891  * only latin letters, digits, and some punctuation.
0892  * See utypes.h for details.
0893  *
0894  * A pair of macros for a single string must be used with the same
0895  * parameters.
0896  * The string parameter must be a C string literal.
0897  * The length of the string, not including the terminating
0898  * `NUL`, must be specified as a constant.
0899  * The U_STRING_DECL macro should be invoked exactly once for one
0900  * such string variable before it is used.
0901  *
0902  * Usage:
0903  *
0904  *     U_STRING_DECL(ustringVar1, "Quick-Fox 2", 11);
0905  *     U_STRING_DECL(ustringVar2, "jumps 5%", 8);
0906  *     static UBool didInit=false;
0907  *
0908  *     int32_t function() {
0909  *         if(!didInit) {
0910  *             U_STRING_INIT(ustringVar1, "Quick-Fox 2", 11);
0911  *             U_STRING_INIT(ustringVar2, "jumps 5%", 8);
0912  *             didInit=true;
0913  *         }
0914  *         return u_strcmp(ustringVar1, ustringVar2);
0915  *     }
0916  * 
0917  * Note that the macros will NOT consistently work if their argument is another #`define`.
0918  * The following will not work on all platforms, don't use it.
0919  * 
0920  *     #define GLUCK "Mr. Gluck"
0921  *     U_STRING_DECL(var, GLUCK, 9)
0922  *     U_STRING_INIT(var, GLUCK, 9)
0923  *
0924  * Instead, use the string literal "Mr. Gluck"  as the argument to both macro
0925  * calls.
0926  *
0927  *
0928  * @stable ICU 2.0
0929  */
0930 #if defined(U_DECLARE_UTF16)
0931 #   define U_STRING_DECL(var, cs, length) static const UChar *var=(const UChar *)U_DECLARE_UTF16(cs)
0932     /**@stable ICU 2.0 */
0933 #   define U_STRING_INIT(var, cs, length)
0934 #elif U_SIZEOF_WCHAR_T==U_SIZEOF_UCHAR && (U_CHARSET_FAMILY==U_ASCII_FAMILY || defined(U_WCHAR_IS_UTF16))
0935 #   define U_STRING_DECL(var, cs, length) static const UChar var[(length)+1]=L ## cs
0936     /**@stable ICU 2.0 */
0937 #   define U_STRING_INIT(var, cs, length)
0938 #else
0939 #   define U_STRING_DECL(var, cs, length) static UChar var[(length)+1]
0940     /**@stable ICU 2.0 */
0941 #   define U_STRING_INIT(var, cs, length) u_charsToUChars(cs, var, length+1)
0942 #endif
0943 
0944 /**
0945  * Unescape a string of characters and write the resulting
0946  * Unicode characters to the destination buffer.  The following escape
0947  * sequences are recognized:
0948  *
0949  * \\uhhhh       4 hex digits; h in [0-9A-Fa-f]
0950  * \\Uhhhhhhhh   8 hex digits
0951  * \\xhh         1-2 hex digits
0952  * \\x{h...}     1-8 hex digits
0953  * \\ooo         1-3 octal digits; o in [0-7]
0954  * \\cX          control-X; X is masked with 0x1F
0955  *
0956  * as well as the standard ANSI C escapes:
0957  *
0958  * \\a => U+0007, \\b => U+0008, \\t => U+0009, \\n => U+000A,
0959  * \\v => U+000B, \\f => U+000C, \\r => U+000D, \\e => U+001B,
0960  * \\&quot; => U+0022, \\' => U+0027, \\? => U+003F, \\\\ => U+005C
0961  *
0962  * Anything else following a backslash is generically escaped.  For
0963  * example, "[a\\-z]" returns "[a-z]".
0964  *
0965  * If an escape sequence is ill-formed, this method returns an empty
0966  * string.  An example of an ill-formed sequence is "\\u" followed by
0967  * fewer than 4 hex digits.
0968  *
0969  * The above characters are recognized in the compiler's codepage,
0970  * that is, they are coded as 'u', '\\', etc.  Characters that are
0971  * not parts of escape sequences are converted using u_charsToUChars().
0972  *
0973  * This function is similar to UnicodeString::unescape() but not
0974  * identical to it.  The latter takes a source UnicodeString, so it
0975  * does escape recognition but no conversion.
0976  *
0977  * @param src a zero-terminated string of invariant characters
0978  * @param dest pointer to buffer to receive converted and unescaped
0979  * text and, if there is room, a zero terminator.  May be NULL for
0980  * preflighting, in which case no UChars will be written, but the
0981  * return value will still be valid.  On error, an empty string is
0982  * stored here (if possible).
0983  * @param destCapacity the number of UChars that may be written at
0984  * dest.  Ignored if dest == NULL.
0985  * @return the length of unescaped string.
0986  * @see u_unescapeAt
0987  * @see UnicodeString#unescape()
0988  * @see UnicodeString#unescapeAt()
0989  * @stable ICU 2.0
0990  */
0991 U_CAPI int32_t U_EXPORT2
0992 u_unescape(const char *src,
0993            UChar *dest, int32_t destCapacity);
0994 
0995 U_CDECL_BEGIN
0996 /**
0997  * Callback function for u_unescapeAt() that returns a character of
0998  * the source text given an offset and a context pointer.  The context
0999  * pointer will be whatever is passed into u_unescapeAt().
1000  *
1001  * @param offset pointer to the offset that will be passed to u_unescapeAt().
1002  * @param context an opaque pointer passed directly into u_unescapeAt()
1003  * @return the character represented by the escape sequence at
1004  * offset
1005  * @see u_unescapeAt
1006  * @stable ICU 2.0
1007  */
1008 typedef UChar (U_CALLCONV *UNESCAPE_CHAR_AT)(int32_t offset, void *context);
1009 U_CDECL_END
1010 
1011 /**
1012  * Unescape a single sequence. The character at offset-1 is assumed
1013  * (without checking) to be a backslash.  This method takes a callback
1014  * pointer to a function that returns the UChar at a given offset.  By
1015  * varying this callback, ICU functions are able to unescape char*
1016  * strings, UnicodeString objects, and UFILE pointers.
1017  *
1018  * If offset is out of range, or if the escape sequence is ill-formed,
1019  * (UChar32)0xFFFFFFFF is returned.  See documentation of u_unescape()
1020  * for a list of recognized sequences.
1021  *
1022  * @param charAt callback function that returns a UChar of the source
1023  * text given an offset and a context pointer.
1024  * @param offset pointer to the offset that will be passed to charAt.
1025  * The offset value will be updated upon return to point after the
1026  * last parsed character of the escape sequence.  On error the offset
1027  * is unchanged.
1028  * @param length the number of characters in the source text.  The
1029  * last character of the source text is considered to be at offset
1030  * length-1.
1031  * @param context an opaque pointer passed directly into charAt.
1032  * @return the character represented by the escape sequence at
1033  * offset, or (UChar32)0xFFFFFFFF on error.
1034  * @see u_unescape()
1035  * @see UnicodeString#unescape()
1036  * @see UnicodeString#unescapeAt()
1037  * @stable ICU 2.0
1038  */
1039 U_CAPI UChar32 U_EXPORT2
1040 u_unescapeAt(UNESCAPE_CHAR_AT charAt,
1041              int32_t *offset,
1042              int32_t length,
1043              void *context);
1044 
1045 /**
1046  * Uppercase the characters in a string.
1047  * Casing is locale-dependent and context-sensitive.
1048  * The result may be longer or shorter than the original.
1049  * The source string and the destination buffer are allowed to overlap.
1050  *
1051  * @param dest      A buffer for the result string. The result will be zero-terminated if
1052  *                  the buffer is large enough.
1053  * @param destCapacity The size of the buffer (number of UChars). If it is 0, then
1054  *                  dest may be NULL and the function will only return the length of the result
1055  *                  without writing any of the result string.
1056  * @param src       The original string
1057  * @param srcLength The length of the original string. If -1, then src must be zero-terminated.
1058  * @param locale    The locale to consider, or "" for the root locale or NULL for the default locale.
1059  * @param pErrorCode Must be a valid pointer to an error code value,
1060  *                  which must not indicate a failure before the function call.
1061  * @return The length of the result string. It may be greater than destCapacity. In that case,
1062  *         only some of the result was written to the destination buffer.
1063  * @stable ICU 2.0
1064  */
1065 U_CAPI int32_t U_EXPORT2
1066 u_strToUpper(UChar *dest, int32_t destCapacity,
1067              const UChar *src, int32_t srcLength,
1068              const char *locale,
1069              UErrorCode *pErrorCode);
1070 
1071 /**
1072  * Lowercase the characters in a string.
1073  * Casing is locale-dependent and context-sensitive.
1074  * The result may be longer or shorter than the original.
1075  * The source string and the destination buffer are allowed to overlap.
1076  *
1077  * @param dest      A buffer for the result string. The result will be zero-terminated if
1078  *                  the buffer is large enough.
1079  * @param destCapacity The size of the buffer (number of UChars). If it is 0, then
1080  *                  dest may be NULL and the function will only return the length of the result
1081  *                  without writing any of the result string.
1082  * @param src       The original string
1083  * @param srcLength The length of the original string. If -1, then src must be zero-terminated.
1084  * @param locale    The locale to consider, or "" for the root locale or NULL for the default locale.
1085  * @param pErrorCode Must be a valid pointer to an error code value,
1086  *                  which must not indicate a failure before the function call.
1087  * @return The length of the result string. It may be greater than destCapacity. In that case,
1088  *         only some of the result was written to the destination buffer.
1089  * @stable ICU 2.0
1090  */
1091 U_CAPI int32_t U_EXPORT2
1092 u_strToLower(UChar *dest, int32_t destCapacity,
1093              const UChar *src, int32_t srcLength,
1094              const char *locale,
1095              UErrorCode *pErrorCode);
1096 
1097 #if !UCONFIG_NO_BREAK_ITERATION
1098 
1099 /**
1100  * Titlecase a string.
1101  * Casing is locale-dependent and context-sensitive.
1102  * Titlecasing uses a break iterator to find the first characters of words
1103  * that are to be titlecased. It titlecases those characters and lowercases
1104  * all others.
1105  *
1106  * The titlecase break iterator can be provided to customize for arbitrary
1107  * styles, using rules and dictionaries beyond the standard iterators.
1108  * It may be more efficient to always provide an iterator to avoid
1109  * opening and closing one for each string.
1110  * The standard titlecase iterator for the root locale implements the
1111  * algorithm of Unicode TR 21.
1112  *
1113  * This function uses only the setText(), first() and next() methods of the
1114  * provided break iterator.
1115  *
1116  * The result may be longer or shorter than the original.
1117  * The source string and the destination buffer are allowed to overlap.
1118  *
1119  * @param dest      A buffer for the result string. The result will be zero-terminated if
1120  *                  the buffer is large enough.
1121  * @param destCapacity The size of the buffer (number of UChars). If it is 0, then
1122  *                  dest may be NULL and the function will only return the length of the result
1123  *                  without writing any of the result string.
1124  * @param src       The original string
1125  * @param srcLength The length of the original string. If -1, then src must be zero-terminated.
1126  * @param titleIter A break iterator to find the first characters of words
1127  *                  that are to be titlecased.
1128  *                  If none is provided (NULL), then a standard titlecase
1129  *                  break iterator is opened.
1130  * @param locale    The locale to consider, or "" for the root locale or NULL for the default locale.
1131  * @param pErrorCode Must be a valid pointer to an error code value,
1132  *                  which must not indicate a failure before the function call.
1133  * @return The length of the result string. It may be greater than destCapacity. In that case,
1134  *         only some of the result was written to the destination buffer.
1135  * @stable ICU 2.1
1136  */
1137 U_CAPI int32_t U_EXPORT2
1138 u_strToTitle(UChar *dest, int32_t destCapacity,
1139              const UChar *src, int32_t srcLength,
1140              UBreakIterator *titleIter,
1141              const char *locale,
1142              UErrorCode *pErrorCode);
1143 
1144 #endif
1145 
1146 /**
1147  * Case-folds the characters in a string.
1148  *
1149  * Case-folding is locale-independent and not context-sensitive,
1150  * but there is an option for whether to include or exclude mappings for dotted I
1151  * and dotless i that are marked with 'T' in CaseFolding.txt.
1152  *
1153  * The result may be longer or shorter than the original.
1154  * The source string and the destination buffer are allowed to overlap.
1155  *
1156  * @param dest      A buffer for the result string. The result will be zero-terminated if
1157  *                  the buffer is large enough.
1158  * @param destCapacity The size of the buffer (number of UChars). If it is 0, then
1159  *                  dest may be NULL and the function will only return the length of the result
1160  *                  without writing any of the result string.
1161  * @param src       The original string
1162  * @param srcLength The length of the original string. If -1, then src must be zero-terminated.
1163  * @param options   Either U_FOLD_CASE_DEFAULT or U_FOLD_CASE_EXCLUDE_SPECIAL_I
1164  * @param pErrorCode Must be a valid pointer to an error code value,
1165  *                  which must not indicate a failure before the function call.
1166  * @return The length of the result string. It may be greater than destCapacity. In that case,
1167  *         only some of the result was written to the destination buffer.
1168  * @stable ICU 2.0
1169  */
1170 U_CAPI int32_t U_EXPORT2
1171 u_strFoldCase(UChar *dest, int32_t destCapacity,
1172               const UChar *src, int32_t srcLength,
1173               uint32_t options,
1174               UErrorCode *pErrorCode);
1175 
1176 #if defined(U_WCHAR_IS_UTF16) || defined(U_WCHAR_IS_UTF32) || !UCONFIG_NO_CONVERSION
1177 /**
1178  * Convert a UTF-16 string to a wchar_t string.
1179  * If it is known at compile time that wchar_t strings are in UTF-16 or UTF-32, then
1180  * this function simply calls the fast, dedicated function for that.
1181  * Otherwise, two conversions UTF-16 -> default charset -> wchar_t* are performed.
1182  *
1183  * @param dest          A buffer for the result string. The result will be zero-terminated if
1184  *                      the buffer is large enough.
1185  * @param destCapacity  The size of the buffer (number of wchar_t's). If it is 0, then
1186  *                      dest may be NULL and the function will only return the length of the 
1187  *                      result without writing any of the result string (pre-flighting).
1188  * @param pDestLength   A pointer to receive the number of units written to the destination. If 
1189  *                      pDestLength!=NULL then *pDestLength is always set to the 
1190  *                      number of output units corresponding to the transformation of 
1191  *                      all the input units, even in case of a buffer overflow.
1192  * @param src           The original source string
1193  * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
1194  * @param pErrorCode    Must be a valid pointer to an error code value,
1195  *                      which must not indicate a failure before the function call.
1196  * @return The pointer to destination buffer.
1197  * @stable ICU 2.0
1198  */
1199 U_CAPI wchar_t* U_EXPORT2
1200 u_strToWCS(wchar_t *dest, 
1201            int32_t destCapacity,
1202            int32_t *pDestLength,
1203            const UChar *src, 
1204            int32_t srcLength,
1205            UErrorCode *pErrorCode);
1206 /**
1207  * Convert a wchar_t string to UTF-16.
1208  * If it is known at compile time that wchar_t strings are in UTF-16 or UTF-32, then
1209  * this function simply calls the fast, dedicated function for that.
1210  * Otherwise, two conversions wchar_t* -> default charset -> UTF-16 are performed.
1211  *
1212  * @param dest          A buffer for the result string. The result will be zero-terminated if
1213  *                      the buffer is large enough.
1214  * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then
1215  *                      dest may be NULL and the function will only return the length of the 
1216  *                      result without writing any of the result string (pre-flighting).
1217  * @param pDestLength   A pointer to receive the number of units written to the destination. If 
1218  *                      pDestLength!=NULL then *pDestLength is always set to the 
1219  *                      number of output units corresponding to the transformation of 
1220  *                      all the input units, even in case of a buffer overflow.
1221  * @param src           The original source string
1222  * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
1223  * @param pErrorCode    Must be a valid pointer to an error code value,
1224  *                      which must not indicate a failure before the function call.
1225  * @return The pointer to destination buffer.
1226  * @stable ICU 2.0
1227  */
1228 U_CAPI UChar* U_EXPORT2
1229 u_strFromWCS(UChar   *dest,
1230              int32_t destCapacity, 
1231              int32_t *pDestLength,
1232              const wchar_t *src,
1233              int32_t srcLength,
1234              UErrorCode *pErrorCode);
1235 #endif /* defined(U_WCHAR_IS_UTF16) || defined(U_WCHAR_IS_UTF32) || !UCONFIG_NO_CONVERSION */
1236 
1237 /**
1238  * Convert a UTF-16 string to UTF-8.
1239  * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set.
1240  *
1241  * @param dest          A buffer for the result string. The result will be zero-terminated if
1242  *                      the buffer is large enough.
1243  * @param destCapacity  The size of the buffer (number of chars). If it is 0, then
1244  *                      dest may be NULL and the function will only return the length of the 
1245  *                      result without writing any of the result string (pre-flighting).
1246  * @param pDestLength   A pointer to receive the number of units written to the destination. If 
1247  *                      pDestLength!=NULL then *pDestLength is always set to the 
1248  *                      number of output units corresponding to the transformation of 
1249  *                      all the input units, even in case of a buffer overflow.
1250  * @param src           The original source string
1251  * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
1252  * @param pErrorCode    Must be a valid pointer to an error code value,
1253  *                      which must not indicate a failure before the function call.
1254  * @return The pointer to destination buffer.
1255  * @stable ICU 2.0
1256  * @see u_strToUTF8WithSub
1257  * @see u_strFromUTF8
1258  */
1259 U_CAPI char* U_EXPORT2 
1260 u_strToUTF8(char *dest,           
1261             int32_t destCapacity,
1262             int32_t *pDestLength,
1263             const UChar *src, 
1264             int32_t srcLength,
1265             UErrorCode *pErrorCode);
1266 
1267 /**
1268  * Convert a UTF-8 string to UTF-16.
1269  * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set.
1270  *
1271  * @param dest          A buffer for the result string. The result will be zero-terminated if
1272  *                      the buffer is large enough.
1273  * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then
1274  *                      dest may be NULL and the function will only return the length of the 
1275  *                      result without writing any of the result string (pre-flighting).
1276  * @param pDestLength   A pointer to receive the number of units written to the destination. If 
1277  *                      pDestLength!=NULL then *pDestLength is always set to the 
1278  *                      number of output units corresponding to the transformation of 
1279  *                      all the input units, even in case of a buffer overflow.
1280  * @param src           The original source string
1281  * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
1282  * @param pErrorCode    Must be a valid pointer to an error code value,
1283  *                      which must not indicate a failure before the function call.
1284  * @return The pointer to destination buffer.
1285  * @stable ICU 2.0
1286  * @see u_strFromUTF8WithSub
1287  * @see u_strFromUTF8Lenient
1288  */
1289 U_CAPI UChar* U_EXPORT2
1290 u_strFromUTF8(UChar *dest,             
1291               int32_t destCapacity,
1292               int32_t *pDestLength,
1293               const char *src, 
1294               int32_t srcLength,
1295               UErrorCode *pErrorCode);
1296 
1297 /**
1298  * Convert a UTF-16 string to UTF-8.
1299  *
1300  * Same as u_strToUTF8() except for the additional subchar which is output for
1301  * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code.
1302  * With subchar==U_SENTINEL, this function behaves exactly like u_strToUTF8().
1303  *
1304  * @param dest          A buffer for the result string. The result will be zero-terminated if
1305  *                      the buffer is large enough.
1306  * @param destCapacity  The size of the buffer (number of chars). If it is 0, then
1307  *                      dest may be NULL and the function will only return the length of the 
1308  *                      result without writing any of the result string (pre-flighting).
1309  * @param pDestLength   A pointer to receive the number of units written to the destination. If 
1310  *                      pDestLength!=NULL then *pDestLength is always set to the 
1311  *                      number of output units corresponding to the transformation of 
1312  *                      all the input units, even in case of a buffer overflow.
1313  * @param src           The original source string
1314  * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
1315  * @param subchar       The substitution character to use in place of an illegal input sequence,
1316  *                      or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead.
1317  *                      A substitution character can be any valid Unicode code point (up to U+10FFFF)
1318  *                      except for surrogate code points (U+D800..U+DFFF).
1319  *                      The recommended value is U+FFFD "REPLACEMENT CHARACTER".
1320  * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0.
1321  *                      Set to 0 if no substitutions occur or subchar<0.
1322  *                      pNumSubstitutions can be NULL.
1323  * @param pErrorCode    Pointer to a standard ICU error code. Its input value must
1324  *                      pass the U_SUCCESS() test, or else the function returns
1325  *                      immediately. Check for U_FAILURE() on output or use with
1326  *                      function chaining. (See User Guide for details.)
1327  * @return The pointer to destination buffer.
1328  * @see u_strToUTF8
1329  * @see u_strFromUTF8WithSub
1330  * @stable ICU 3.6
1331  */
1332 U_CAPI char* U_EXPORT2
1333 u_strToUTF8WithSub(char *dest,
1334             int32_t destCapacity,
1335             int32_t *pDestLength,
1336             const UChar *src,
1337             int32_t srcLength,
1338             UChar32 subchar, int32_t *pNumSubstitutions,
1339             UErrorCode *pErrorCode);
1340 
1341 /**
1342  * Convert a UTF-8 string to UTF-16.
1343  *
1344  * Same as u_strFromUTF8() except for the additional subchar which is output for
1345  * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code.
1346  * With subchar==U_SENTINEL, this function behaves exactly like u_strFromUTF8().
1347  *
1348  * @param dest          A buffer for the result string. The result will be zero-terminated if
1349  *                      the buffer is large enough.
1350  * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then
1351  *                      dest may be NULL and the function will only return the length of the 
1352  *                      result without writing any of the result string (pre-flighting).
1353  * @param pDestLength   A pointer to receive the number of units written to the destination. If 
1354  *                      pDestLength!=NULL then *pDestLength is always set to the 
1355  *                      number of output units corresponding to the transformation of 
1356  *                      all the input units, even in case of a buffer overflow.
1357  * @param src           The original source string
1358  * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
1359  * @param subchar       The substitution character to use in place of an illegal input sequence,
1360  *                      or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead.
1361  *                      A substitution character can be any valid Unicode code point (up to U+10FFFF)
1362  *                      except for surrogate code points (U+D800..U+DFFF).
1363  *                      The recommended value is U+FFFD "REPLACEMENT CHARACTER".
1364  * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0.
1365  *                      Set to 0 if no substitutions occur or subchar<0.
1366  *                      pNumSubstitutions can be NULL.
1367  * @param pErrorCode    Pointer to a standard ICU error code. Its input value must
1368  *                      pass the U_SUCCESS() test, or else the function returns
1369  *                      immediately. Check for U_FAILURE() on output or use with
1370  *                      function chaining. (See User Guide for details.)
1371  * @return The pointer to destination buffer.
1372  * @see u_strFromUTF8
1373  * @see u_strFromUTF8Lenient
1374  * @see u_strToUTF8WithSub
1375  * @stable ICU 3.6
1376  */
1377 U_CAPI UChar* U_EXPORT2
1378 u_strFromUTF8WithSub(UChar *dest,
1379               int32_t destCapacity,
1380               int32_t *pDestLength,
1381               const char *src,
1382               int32_t srcLength,
1383               UChar32 subchar, int32_t *pNumSubstitutions,
1384               UErrorCode *pErrorCode);
1385 
1386 /**
1387  * Convert a UTF-8 string to UTF-16.
1388  *
1389  * Same as u_strFromUTF8() except that this function is designed to be very fast,
1390  * which it achieves by being lenient about malformed UTF-8 sequences.
1391  * This function is intended for use in environments where UTF-8 text is
1392  * expected to be well-formed.
1393  *
1394  * Its semantics are:
1395  * - Well-formed UTF-8 text is correctly converted to well-formed UTF-16 text.
1396  * - The function will not read beyond the input string, nor write beyond
1397  *   the destCapacity.
1398  * - Malformed UTF-8 results in "garbage" 16-bit Unicode strings which may not
1399  *   be well-formed UTF-16.
1400  *   The function will resynchronize to valid code point boundaries
1401  *   within a small number of code points after an illegal sequence.
1402  * - Non-shortest forms are not detected and will result in "spoofing" output.
1403  *
1404  * For further performance improvement, if srcLength is given (>=0),
1405  * then it must be destCapacity>=srcLength.
1406  *
1407  * There is no inverse u_strToUTF8Lenient() function because there is practically
1408  * no performance gain from not checking that a UTF-16 string is well-formed.
1409  *
1410  * @param dest          A buffer for the result string. The result will be zero-terminated if
1411  *                      the buffer is large enough.
1412  * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then
1413  *                      dest may be NULL and the function will only return the length of the 
1414  *                      result without writing any of the result string (pre-flighting).
1415  *                      Unlike for other ICU functions, if srcLength>=0 then it
1416  *                      must be destCapacity>=srcLength.
1417  * @param pDestLength   A pointer to receive the number of units written to the destination. If 
1418  *                      pDestLength!=NULL then *pDestLength is always set to the 
1419  *                      number of output units corresponding to the transformation of 
1420  *                      all the input units, even in case of a buffer overflow.
1421  *                      Unlike for other ICU functions, if srcLength>=0 but
1422  *                      destCapacity<srcLength, then *pDestLength will be set to srcLength
1423  *                      (and U_BUFFER_OVERFLOW_ERROR will be set)
1424  *                      regardless of the actual result length.
1425  * @param src           The original source string
1426  * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
1427  * @param pErrorCode    Pointer to a standard ICU error code. Its input value must
1428  *                      pass the U_SUCCESS() test, or else the function returns
1429  *                      immediately. Check for U_FAILURE() on output or use with
1430  *                      function chaining. (See User Guide for details.)
1431  * @return The pointer to destination buffer.
1432  * @see u_strFromUTF8
1433  * @see u_strFromUTF8WithSub
1434  * @see u_strToUTF8WithSub
1435  * @stable ICU 3.6
1436  */
1437 U_CAPI UChar * U_EXPORT2
1438 u_strFromUTF8Lenient(UChar *dest,
1439                      int32_t destCapacity,
1440                      int32_t *pDestLength,
1441                      const char *src,
1442                      int32_t srcLength,
1443                      UErrorCode *pErrorCode);
1444 
1445 /**
1446  * Convert a UTF-16 string to UTF-32.
1447  * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set.
1448  *
1449  * @param dest          A buffer for the result string. The result will be zero-terminated if
1450  *                      the buffer is large enough.
1451  * @param destCapacity  The size of the buffer (number of UChar32s). If it is 0, then
1452  *                      dest may be NULL and the function will only return the length of the 
1453  *                      result without writing any of the result string (pre-flighting).
1454  * @param pDestLength   A pointer to receive the number of units written to the destination. If 
1455  *                      pDestLength!=NULL then *pDestLength is always set to the 
1456  *                      number of output units corresponding to the transformation of 
1457  *                      all the input units, even in case of a buffer overflow.
1458  * @param src           The original source string
1459  * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
1460  * @param pErrorCode    Must be a valid pointer to an error code value,
1461  *                      which must not indicate a failure before the function call.
1462  * @return The pointer to destination buffer.
1463  * @see u_strToUTF32WithSub
1464  * @see u_strFromUTF32
1465  * @stable ICU 2.0
1466  */
1467 U_CAPI UChar32* U_EXPORT2 
1468 u_strToUTF32(UChar32 *dest, 
1469              int32_t  destCapacity,
1470              int32_t  *pDestLength,
1471              const UChar *src, 
1472              int32_t  srcLength,
1473              UErrorCode *pErrorCode);
1474 
1475 /**
1476  * Convert a UTF-32 string to UTF-16.
1477  * If the input string is not well-formed, then the U_INVALID_CHAR_FOUND error code is set.
1478  *
1479  * @param dest          A buffer for the result string. The result will be zero-terminated if
1480  *                      the buffer is large enough.
1481  * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then
1482  *                      dest may be NULL and the function will only return the length of the 
1483  *                      result without writing any of the result string (pre-flighting).
1484  * @param pDestLength   A pointer to receive the number of units written to the destination. If 
1485  *                      pDestLength!=NULL then *pDestLength is always set to the 
1486  *                      number of output units corresponding to the transformation of 
1487  *                      all the input units, even in case of a buffer overflow.
1488  * @param src           The original source string
1489  * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
1490  * @param pErrorCode    Must be a valid pointer to an error code value,
1491  *                      which must not indicate a failure before the function call.
1492  * @return The pointer to destination buffer.
1493  * @see u_strFromUTF32WithSub
1494  * @see u_strToUTF32
1495  * @stable ICU 2.0
1496  */
1497 U_CAPI UChar* U_EXPORT2 
1498 u_strFromUTF32(UChar   *dest,
1499                int32_t destCapacity, 
1500                int32_t *pDestLength,
1501                const UChar32 *src,
1502                int32_t srcLength,
1503                UErrorCode *pErrorCode);
1504 
1505 /**
1506  * Convert a UTF-16 string to UTF-32.
1507  *
1508  * Same as u_strToUTF32() except for the additional subchar which is output for
1509  * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code.
1510  * With subchar==U_SENTINEL, this function behaves exactly like u_strToUTF32().
1511  *
1512  * @param dest          A buffer for the result string. The result will be zero-terminated if
1513  *                      the buffer is large enough.
1514  * @param destCapacity  The size of the buffer (number of UChar32s). If it is 0, then
1515  *                      dest may be NULL and the function will only return the length of the
1516  *                      result without writing any of the result string (pre-flighting).
1517  * @param pDestLength   A pointer to receive the number of units written to the destination. If
1518  *                      pDestLength!=NULL then *pDestLength is always set to the
1519  *                      number of output units corresponding to the transformation of
1520  *                      all the input units, even in case of a buffer overflow.
1521  * @param src           The original source string
1522  * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
1523  * @param subchar       The substitution character to use in place of an illegal input sequence,
1524  *                      or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead.
1525  *                      A substitution character can be any valid Unicode code point (up to U+10FFFF)
1526  *                      except for surrogate code points (U+D800..U+DFFF).
1527  *                      The recommended value is U+FFFD "REPLACEMENT CHARACTER".
1528  * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0.
1529  *                      Set to 0 if no substitutions occur or subchar<0.
1530  *                      pNumSubstitutions can be NULL.
1531  * @param pErrorCode    Pointer to a standard ICU error code. Its input value must
1532  *                      pass the U_SUCCESS() test, or else the function returns
1533  *                      immediately. Check for U_FAILURE() on output or use with
1534  *                      function chaining. (See User Guide for details.)
1535  * @return The pointer to destination buffer.
1536  * @see u_strToUTF32
1537  * @see u_strFromUTF32WithSub
1538  * @stable ICU 4.2
1539  */
1540 U_CAPI UChar32* U_EXPORT2
1541 u_strToUTF32WithSub(UChar32 *dest,
1542              int32_t destCapacity,
1543              int32_t *pDestLength,
1544              const UChar *src,
1545              int32_t srcLength,
1546              UChar32 subchar, int32_t *pNumSubstitutions,
1547              UErrorCode *pErrorCode);
1548 
1549 /**
1550  * Convert a UTF-32 string to UTF-16.
1551  *
1552  * Same as u_strFromUTF32() except for the additional subchar which is output for
1553  * illegal input sequences, instead of stopping with the U_INVALID_CHAR_FOUND error code.
1554  * With subchar==U_SENTINEL, this function behaves exactly like u_strFromUTF32().
1555  *
1556  * @param dest          A buffer for the result string. The result will be zero-terminated if
1557  *                      the buffer is large enough.
1558  * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then
1559  *                      dest may be NULL and the function will only return the length of the
1560  *                      result without writing any of the result string (pre-flighting).
1561  * @param pDestLength   A pointer to receive the number of units written to the destination. If
1562  *                      pDestLength!=NULL then *pDestLength is always set to the
1563  *                      number of output units corresponding to the transformation of
1564  *                      all the input units, even in case of a buffer overflow.
1565  * @param src           The original source string
1566  * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
1567  * @param subchar       The substitution character to use in place of an illegal input sequence,
1568  *                      or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead.
1569  *                      A substitution character can be any valid Unicode code point (up to U+10FFFF)
1570  *                      except for surrogate code points (U+D800..U+DFFF).
1571  *                      The recommended value is U+FFFD "REPLACEMENT CHARACTER".
1572  * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0.
1573  *                      Set to 0 if no substitutions occur or subchar<0.
1574  *                      pNumSubstitutions can be NULL.
1575  * @param pErrorCode    Pointer to a standard ICU error code. Its input value must
1576  *                      pass the U_SUCCESS() test, or else the function returns
1577  *                      immediately. Check for U_FAILURE() on output or use with
1578  *                      function chaining. (See User Guide for details.)
1579  * @return The pointer to destination buffer.
1580  * @see u_strFromUTF32
1581  * @see u_strToUTF32WithSub
1582  * @stable ICU 4.2
1583  */
1584 U_CAPI UChar* U_EXPORT2
1585 u_strFromUTF32WithSub(UChar *dest,
1586                int32_t destCapacity,
1587                int32_t *pDestLength,
1588                const UChar32 *src,
1589                int32_t srcLength,
1590                UChar32 subchar, int32_t *pNumSubstitutions,
1591                UErrorCode *pErrorCode);
1592 
1593 /**
1594  * Convert a 16-bit Unicode string to Java Modified UTF-8.
1595  * See http://java.sun.com/javase/6/docs/api/java/io/DataInput.html#modified-utf-8
1596  *
1597  * This function behaves according to the documentation for Java DataOutput.writeUTF()
1598  * except that it does not encode the output length in the destination buffer
1599  * and does not have an output length restriction.
1600  * See http://java.sun.com/javase/6/docs/api/java/io/DataOutput.html#writeUTF(java.lang.String)
1601  *
1602  * The input string need not be well-formed UTF-16.
1603  * (Therefore there is no subchar parameter.)
1604  *
1605  * @param dest          A buffer for the result string. The result will be zero-terminated if
1606  *                      the buffer is large enough.
1607  * @param destCapacity  The size of the buffer (number of chars). If it is 0, then
1608  *                      dest may be NULL and the function will only return the length of the 
1609  *                      result without writing any of the result string (pre-flighting).
1610  * @param pDestLength   A pointer to receive the number of units written to the destination. If 
1611  *                      pDestLength!=NULL then *pDestLength is always set to the 
1612  *                      number of output units corresponding to the transformation of 
1613  *                      all the input units, even in case of a buffer overflow.
1614  * @param src           The original source string
1615  * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
1616  * @param pErrorCode    Pointer to a standard ICU error code. Its input value must
1617  *                      pass the U_SUCCESS() test, or else the function returns
1618  *                      immediately. Check for U_FAILURE() on output or use with
1619  *                      function chaining. (See User Guide for details.)
1620  * @return The pointer to destination buffer.
1621  * @stable ICU 4.4
1622  * @see u_strToUTF8WithSub
1623  * @see u_strFromJavaModifiedUTF8WithSub
1624  */
1625 U_CAPI char* U_EXPORT2 
1626 u_strToJavaModifiedUTF8(
1627         char *dest,
1628         int32_t destCapacity,
1629         int32_t *pDestLength,
1630         const UChar *src, 
1631         int32_t srcLength,
1632         UErrorCode *pErrorCode);
1633 
1634 /**
1635  * Convert a Java Modified UTF-8 string to a 16-bit Unicode string.
1636  * If the input string is not well-formed and no substitution char is specified, 
1637  * then the U_INVALID_CHAR_FOUND error code is set.
1638  *
1639  * This function behaves according to the documentation for Java DataInput.readUTF()
1640  * except that it takes a length parameter rather than
1641  * interpreting the first two input bytes as the length.
1642  * See http://java.sun.com/javase/6/docs/api/java/io/DataInput.html#readUTF()
1643  *
1644  * The output string may not be well-formed UTF-16.
1645  *
1646  * @param dest          A buffer for the result string. The result will be zero-terminated if
1647  *                      the buffer is large enough.
1648  * @param destCapacity  The size of the buffer (number of UChars). If it is 0, then
1649  *                      dest may be NULL and the function will only return the length of the 
1650  *                      result without writing any of the result string (pre-flighting).
1651  * @param pDestLength   A pointer to receive the number of units written to the destination. If 
1652  *                      pDestLength!=NULL then *pDestLength is always set to the 
1653  *                      number of output units corresponding to the transformation of 
1654  *                      all the input units, even in case of a buffer overflow.
1655  * @param src           The original source string
1656  * @param srcLength     The length of the original string. If -1, then src must be zero-terminated.
1657  * @param subchar       The substitution character to use in place of an illegal input sequence,
1658  *                      or U_SENTINEL if the function is to return with U_INVALID_CHAR_FOUND instead.
1659  *                      A substitution character can be any valid Unicode code point (up to U+10FFFF)
1660  *                      except for surrogate code points (U+D800..U+DFFF).
1661  *                      The recommended value is U+FFFD "REPLACEMENT CHARACTER".
1662  * @param pNumSubstitutions Output parameter receiving the number of substitutions if subchar>=0.
1663  *                      Set to 0 if no substitutions occur or subchar<0.
1664  *                      pNumSubstitutions can be NULL.
1665  * @param pErrorCode    Pointer to a standard ICU error code. Its input value must
1666  *                      pass the U_SUCCESS() test, or else the function returns
1667  *                      immediately. Check for U_FAILURE() on output or use with
1668  *                      function chaining. (See User Guide for details.)
1669  * @return The pointer to destination buffer.
1670  * @see u_strFromUTF8WithSub
1671  * @see u_strFromUTF8Lenient
1672  * @see u_strToJavaModifiedUTF8
1673  * @stable ICU 4.4
1674  */
1675 U_CAPI UChar* U_EXPORT2
1676 u_strFromJavaModifiedUTF8WithSub(
1677         UChar *dest,
1678         int32_t destCapacity,
1679         int32_t *pDestLength,
1680         const char *src,
1681         int32_t srcLength,
1682         UChar32 subchar, int32_t *pNumSubstitutions,
1683         UErrorCode *pErrorCode);
1684 
1685 #endif