annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/unicode/usprep.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 // © 2016 and later: Unicode, Inc. and others.
jpayne@69 2 // License & terms of use: http://www.unicode.org/copyright.html
jpayne@69 3 /*
jpayne@69 4 *******************************************************************************
jpayne@69 5 *
jpayne@69 6 * Copyright (C) 2003-2014, International Business Machines
jpayne@69 7 * Corporation and others. All Rights Reserved.
jpayne@69 8 *
jpayne@69 9 *******************************************************************************
jpayne@69 10 * file name: usprep.h
jpayne@69 11 * encoding: UTF-8
jpayne@69 12 * tab size: 8 (not used)
jpayne@69 13 * indentation:4
jpayne@69 14 *
jpayne@69 15 * created on: 2003jul2
jpayne@69 16 * created by: Ram Viswanadha
jpayne@69 17 */
jpayne@69 18
jpayne@69 19 #ifndef __USPREP_H__
jpayne@69 20 #define __USPREP_H__
jpayne@69 21
jpayne@69 22 /**
jpayne@69 23 * \file
jpayne@69 24 * \brief C API: Implements the StringPrep algorithm.
jpayne@69 25 */
jpayne@69 26
jpayne@69 27 #include "unicode/utypes.h"
jpayne@69 28 #include "unicode/localpointer.h"
jpayne@69 29
jpayne@69 30 /**
jpayne@69 31 *
jpayne@69 32 * StringPrep API implements the StingPrep framework as described by RFC 3454.
jpayne@69 33 * StringPrep prepares Unicode strings for use in network protocols.
jpayne@69 34 * Profiles of StingPrep are set of rules and data according to with the
jpayne@69 35 * Unicode Strings are prepared. Each profiles contains tables which describe
jpayne@69 36 * how a code point should be treated. The tables are broadly classified into
jpayne@69 37 * <ul>
jpayne@69 38 * <li> Unassigned Table: Contains code points that are unassigned
jpayne@69 39 * in the Unicode Version supported by StringPrep. Currently
jpayne@69 40 * RFC 3454 supports Unicode 3.2. </li>
jpayne@69 41 * <li> Prohibited Table: Contains code points that are prohibited from
jpayne@69 42 * the output of the StringPrep processing function. </li>
jpayne@69 43 * <li> Mapping Table: Contains code points that are deleted from the output or case mapped. </li>
jpayne@69 44 * </ul>
jpayne@69 45 *
jpayne@69 46 * The procedure for preparing Unicode strings:
jpayne@69 47 * <ol>
jpayne@69 48 * <li> Map: For each character in the input, check if it has a mapping
jpayne@69 49 * and, if so, replace it with its mapping. </li>
jpayne@69 50 * <li> Normalize: Possibly normalize the result of step 1 using Unicode
jpayne@69 51 * normalization. </li>
jpayne@69 52 * <li> Prohibit: Check for any characters that are not allowed in the
jpayne@69 53 * output. If any are found, return an error.</li>
jpayne@69 54 * <li> Check bidi: Possibly check for right-to-left characters, and if
jpayne@69 55 * any are found, make sure that the whole string satisfies the
jpayne@69 56 * requirements for bidirectional strings. If the string does not
jpayne@69 57 * satisfy the requirements for bidirectional strings, return an
jpayne@69 58 * error. </li>
jpayne@69 59 * </ol>
jpayne@69 60 * @author Ram Viswanadha
jpayne@69 61 */
jpayne@69 62 #if !UCONFIG_NO_IDNA
jpayne@69 63
jpayne@69 64 #include "unicode/parseerr.h"
jpayne@69 65
jpayne@69 66 /**
jpayne@69 67 * The StringPrep profile
jpayne@69 68 * @stable ICU 2.8
jpayne@69 69 */
jpayne@69 70 typedef struct UStringPrepProfile UStringPrepProfile;
jpayne@69 71
jpayne@69 72
jpayne@69 73 /**
jpayne@69 74 * Option to prohibit processing of unassigned code points in the input
jpayne@69 75 *
jpayne@69 76 * @see usprep_prepare
jpayne@69 77 * @stable ICU 2.8
jpayne@69 78 */
jpayne@69 79 #define USPREP_DEFAULT 0x0000
jpayne@69 80
jpayne@69 81 /**
jpayne@69 82 * Option to allow processing of unassigned code points in the input
jpayne@69 83 *
jpayne@69 84 * @see usprep_prepare
jpayne@69 85 * @stable ICU 2.8
jpayne@69 86 */
jpayne@69 87 #define USPREP_ALLOW_UNASSIGNED 0x0001
jpayne@69 88
jpayne@69 89 /**
jpayne@69 90 * enums for the standard stringprep profile types
jpayne@69 91 * supported by usprep_openByType.
jpayne@69 92 * @see usprep_openByType
jpayne@69 93 * @stable ICU 4.2
jpayne@69 94 */
jpayne@69 95 typedef enum UStringPrepProfileType {
jpayne@69 96 /**
jpayne@69 97 * RFC3491 Nameprep
jpayne@69 98 * @stable ICU 4.2
jpayne@69 99 */
jpayne@69 100 USPREP_RFC3491_NAMEPREP,
jpayne@69 101 /**
jpayne@69 102 * RFC3530 nfs4_cs_prep
jpayne@69 103 * @stable ICU 4.2
jpayne@69 104 */
jpayne@69 105 USPREP_RFC3530_NFS4_CS_PREP,
jpayne@69 106 /**
jpayne@69 107 * RFC3530 nfs4_cs_prep with case insensitive option
jpayne@69 108 * @stable ICU 4.2
jpayne@69 109 */
jpayne@69 110 USPREP_RFC3530_NFS4_CS_PREP_CI,
jpayne@69 111 /**
jpayne@69 112 * RFC3530 nfs4_cis_prep
jpayne@69 113 * @stable ICU 4.2
jpayne@69 114 */
jpayne@69 115 USPREP_RFC3530_NFS4_CIS_PREP,
jpayne@69 116 /**
jpayne@69 117 * RFC3530 nfs4_mixed_prep for prefix
jpayne@69 118 * @stable ICU 4.2
jpayne@69 119 */
jpayne@69 120 USPREP_RFC3530_NFS4_MIXED_PREP_PREFIX,
jpayne@69 121 /**
jpayne@69 122 * RFC3530 nfs4_mixed_prep for suffix
jpayne@69 123 * @stable ICU 4.2
jpayne@69 124 */
jpayne@69 125 USPREP_RFC3530_NFS4_MIXED_PREP_SUFFIX,
jpayne@69 126 /**
jpayne@69 127 * RFC3722 iSCSI
jpayne@69 128 * @stable ICU 4.2
jpayne@69 129 */
jpayne@69 130 USPREP_RFC3722_ISCSI,
jpayne@69 131 /**
jpayne@69 132 * RFC3920 XMPP Nodeprep
jpayne@69 133 * @stable ICU 4.2
jpayne@69 134 */
jpayne@69 135 USPREP_RFC3920_NODEPREP,
jpayne@69 136 /**
jpayne@69 137 * RFC3920 XMPP Resourceprep
jpayne@69 138 * @stable ICU 4.2
jpayne@69 139 */
jpayne@69 140 USPREP_RFC3920_RESOURCEPREP,
jpayne@69 141 /**
jpayne@69 142 * RFC4011 Policy MIB Stringprep
jpayne@69 143 * @stable ICU 4.2
jpayne@69 144 */
jpayne@69 145 USPREP_RFC4011_MIB,
jpayne@69 146 /**
jpayne@69 147 * RFC4013 SASLprep
jpayne@69 148 * @stable ICU 4.2
jpayne@69 149 */
jpayne@69 150 USPREP_RFC4013_SASLPREP,
jpayne@69 151 /**
jpayne@69 152 * RFC4505 trace
jpayne@69 153 * @stable ICU 4.2
jpayne@69 154 */
jpayne@69 155 USPREP_RFC4505_TRACE,
jpayne@69 156 /**
jpayne@69 157 * RFC4518 LDAP
jpayne@69 158 * @stable ICU 4.2
jpayne@69 159 */
jpayne@69 160 USPREP_RFC4518_LDAP,
jpayne@69 161 /**
jpayne@69 162 * RFC4518 LDAP for case ignore, numeric and stored prefix
jpayne@69 163 * matching rules
jpayne@69 164 * @stable ICU 4.2
jpayne@69 165 */
jpayne@69 166 USPREP_RFC4518_LDAP_CI
jpayne@69 167 } UStringPrepProfileType;
jpayne@69 168
jpayne@69 169 /**
jpayne@69 170 * Creates a StringPrep profile from the data file.
jpayne@69 171 *
jpayne@69 172 * @param path string containing the full path pointing to the directory
jpayne@69 173 * where the profile reside followed by the package name
jpayne@69 174 * e.g. "/usr/resource/my_app/profiles/mydata" on a Unix system.
jpayne@69 175 * if NULL, ICU default data files will be used.
jpayne@69 176 * @param fileName name of the profile file to be opened
jpayne@69 177 * @param status ICU error code in/out parameter. Must not be NULL.
jpayne@69 178 * Must fulfill U_SUCCESS before the function call.
jpayne@69 179 * @return Pointer to UStringPrepProfile that is opened. Should be closed by
jpayne@69 180 * calling usprep_close()
jpayne@69 181 * @see usprep_close()
jpayne@69 182 * @stable ICU 2.8
jpayne@69 183 */
jpayne@69 184 U_STABLE UStringPrepProfile* U_EXPORT2
jpayne@69 185 usprep_open(const char* path,
jpayne@69 186 const char* fileName,
jpayne@69 187 UErrorCode* status);
jpayne@69 188
jpayne@69 189 /**
jpayne@69 190 * Creates a StringPrep profile for the specified profile type.
jpayne@69 191 *
jpayne@69 192 * @param type The profile type
jpayne@69 193 * @param status ICU error code in/out parameter. Must not be NULL.
jpayne@69 194 * Must fulfill U_SUCCESS before the function call.
jpayne@69 195 * @return Pointer to UStringPrepProfile that is opened. Should be closed by
jpayne@69 196 * calling usprep_close()
jpayne@69 197 * @see usprep_close()
jpayne@69 198 * @stable ICU 4.2
jpayne@69 199 */
jpayne@69 200 U_STABLE UStringPrepProfile* U_EXPORT2
jpayne@69 201 usprep_openByType(UStringPrepProfileType type,
jpayne@69 202 UErrorCode* status);
jpayne@69 203
jpayne@69 204 /**
jpayne@69 205 * Closes the profile
jpayne@69 206 * @param profile The profile to close
jpayne@69 207 * @stable ICU 2.8
jpayne@69 208 */
jpayne@69 209 U_STABLE void U_EXPORT2
jpayne@69 210 usprep_close(UStringPrepProfile* profile);
jpayne@69 211
jpayne@69 212 #if U_SHOW_CPLUSPLUS_API
jpayne@69 213
jpayne@69 214 U_NAMESPACE_BEGIN
jpayne@69 215
jpayne@69 216 /**
jpayne@69 217 * \class LocalUStringPrepProfilePointer
jpayne@69 218 * "Smart pointer" class, closes a UStringPrepProfile via usprep_close().
jpayne@69 219 * For most methods see the LocalPointerBase base class.
jpayne@69 220 *
jpayne@69 221 * @see LocalPointerBase
jpayne@69 222 * @see LocalPointer
jpayne@69 223 * @stable ICU 4.4
jpayne@69 224 */
jpayne@69 225 U_DEFINE_LOCAL_OPEN_POINTER(LocalUStringPrepProfilePointer, UStringPrepProfile, usprep_close);
jpayne@69 226
jpayne@69 227 U_NAMESPACE_END
jpayne@69 228
jpayne@69 229 #endif
jpayne@69 230
jpayne@69 231 /**
jpayne@69 232 * Prepare the input buffer for use in applications with the given profile. This operation maps, normalizes(NFKC),
jpayne@69 233 * checks for prohibited and BiDi characters in the order defined by RFC 3454
jpayne@69 234 * depending on the options specified in the profile.
jpayne@69 235 *
jpayne@69 236 * @param prep The profile to use
jpayne@69 237 * @param src Pointer to UChar buffer containing the string to prepare
jpayne@69 238 * @param srcLength Number of characters in the source string
jpayne@69 239 * @param dest Pointer to the destination buffer to receive the output
jpayne@69 240 * @param destCapacity The capacity of destination array
jpayne@69 241 * @param options A bit set of options:
jpayne@69 242 *
jpayne@69 243 * - USPREP_DEFAULT Prohibit processing of unassigned code points in the input
jpayne@69 244 *
jpayne@69 245 * - USPREP_ALLOW_UNASSIGNED Treat the unassigned code points are in the input
jpayne@69 246 * as normal Unicode code points.
jpayne@69 247 *
jpayne@69 248 * @param parseError Pointer to UParseError struct to receive information on position
jpayne@69 249 * of error if an error is encountered. Can be NULL.
jpayne@69 250 * @param status ICU in/out error code parameter.
jpayne@69 251 * U_INVALID_CHAR_FOUND if src contains
jpayne@69 252 * unmatched single surrogates.
jpayne@69 253 * U_INDEX_OUTOFBOUNDS_ERROR if src contains
jpayne@69 254 * too many code points.
jpayne@69 255 * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
jpayne@69 256 * @return The number of UChars in the destination buffer
jpayne@69 257 * @stable ICU 2.8
jpayne@69 258 */
jpayne@69 259
jpayne@69 260 U_STABLE int32_t U_EXPORT2
jpayne@69 261 usprep_prepare( const UStringPrepProfile* prep,
jpayne@69 262 const UChar* src, int32_t srcLength,
jpayne@69 263 UChar* dest, int32_t destCapacity,
jpayne@69 264 int32_t options,
jpayne@69 265 UParseError* parseError,
jpayne@69 266 UErrorCode* status );
jpayne@69 267
jpayne@69 268
jpayne@69 269 #endif /* #if !UCONFIG_NO_IDNA */
jpayne@69 270
jpayne@69 271 #endif