Update contrib.
2 *******************************************************************************
4 * Copyright (C) 2003-2005, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
10 * tab size: 8 (not used)
13 * created on: 2003jul2
14 * created by: Ram Viswanadha
22 * \brief C API: Implements the StringPrep algorithm.
25 #include "unicode/utypes.h"
28 * StringPrep API implements the StingPrep framework as described by RFC 3454.
29 * StringPrep prepares Unicode strings for use in network protocols.
30 * Profiles of StingPrep are set of rules and data according to with the
31 * Unicode Strings are prepared. Each profiles contains tables which describe
32 * how a code point should be treated. The tables are broadly classied into
34 * <li> Unassinged Table: Contains code points that are unassigned
35 * in the Unicode Version supported by StringPrep. Currently
36 * RFC 3454 supports Unicode 3.2. </li>
37 * <li> Prohibited Table: Contains code points that are prohibted from
38 * the output of the StringPrep processing function. </li>
39 * <li> Mapping Table: Contains code ponts that are deleted from the output or case mapped. </li>
42 * The procedure for preparing Unicode strings:
44 * <li> Map: For each character in the input, check if it has a mapping
45 * and, if so, replace it with its mapping. </li>
46 * <li> Normalize: Possibly normalize the result of step 1 using Unicode
47 * normalization. </li>
48 * <li> Prohibit: Check for any characters that are not allowed in the
49 * output. If any are found, return an error.</li>
50 * <li> Check bidi: Possibly check for right-to-left characters, and if
51 * any are found, make sure that the whole string satisfies the
52 * requirements for bidirectional strings. If the string does not
53 * satisfy the requirements for bidirectional strings, return an
56 * @author Ram Viswanadha
60 #include "unicode/parseerr.h"
62 #ifndef U_HIDE_DRAFT_API
65 * The StringPrep profile
68 typedef struct UStringPrepProfile UStringPrepProfile;
72 * Option to prohibit processing of unassigned code points in the input
77 #define USPREP_DEFAULT 0x0000
80 * Option to allow processing of unassigned code points in the input
85 #define USPREP_ALLOW_UNASSIGNED 0x0001
88 #endif /*U_HIDE_DRAFT_API*/
91 * Creates a StringPrep profile from the data file.
93 * @param path string containing the full path pointing to the directory
94 * where the profile reside followed by the package name
95 * e.g. "/usr/resource/my_app/profiles/mydata" on a Unix system.
96 * if NULL, ICU default data files will be used.
97 * @param fileName name of the profile file to be opened
98 * @param status ICU error code in/out parameter. Must not be NULL.
99 * Must fulfill U_SUCCESS before the function call.
100 * @return Pointer to UStringPrepProfile that is opened. Should be closed by
101 * calling usprep_close()
102 * @see usprep_close()
105 U_STABLE UStringPrepProfile* U_EXPORT2
106 usprep_open(const char* path,
107 const char* fileName,
113 * @param profile The profile to close
116 U_STABLE void U_EXPORT2
117 usprep_close(UStringPrepProfile* profile);
121 * Prepare the input buffer for use in applications with the given profile. This operation maps, normalizes(NFKC),
122 * checks for prohited and BiDi characters in the order defined by RFC 3454
123 * depending on the options specified in the profile.
125 * @param prep The profile to use
126 * @param src Pointer to UChar buffer containing the string to prepare
127 * @param srcLength Number of characters in the source string
128 * @param dest Pointer to the destination buffer to receive the output
129 * @param destCapacity The capacity of destination array
130 * @param options A bit set of options:
132 * - USPREP_NONE Prohibit processing of unassigned code points in the input
134 * - USPREP_ALLOW_UNASSIGNED Treat the unassigned code points are in the input
135 * as normal Unicode code points.
137 * @param parseError Pointer to UParseError struct to receive information on position
138 * of error if an error is encountered. Can be NULL.
139 * @param status ICU in/out error code parameter.
140 * U_INVALID_CHAR_FOUND if src contains
141 * unmatched single surrogates.
142 * U_INDEX_OUTOFBOUNDS_ERROR if src contains
143 * too many code points.
144 * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
145 * @return The number of UChars in the destination buffer
149 U_STABLE int32_t U_EXPORT2
150 usprep_prepare( const UStringPrepProfile* prep,
151 const UChar* src, int32_t srcLength,
152 UChar* dest, int32_t destCapacity,
154 UParseError* parseError,
155 UErrorCode* status );
158 #endif /* #if !UCONFIG_NO_IDNA */