|
||||
Warning, file /include/unicode/uidna.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 * 0006 * Copyright (C) 2003-2014, International Business Machines 0007 * Corporation and others. All Rights Reserved. 0008 * 0009 ******************************************************************************* 0010 * file name: uidna.h 0011 * encoding: UTF-8 0012 * tab size: 8 (not used) 0013 * indentation:4 0014 * 0015 * created on: 2003feb1 0016 * created by: Ram Viswanadha 0017 */ 0018 0019 #ifndef __UIDNA_H__ 0020 #define __UIDNA_H__ 0021 0022 #include "unicode/utypes.h" 0023 0024 #if !UCONFIG_NO_IDNA 0025 0026 #include <stdbool.h> 0027 #include "unicode/parseerr.h" 0028 0029 #if U_SHOW_CPLUSPLUS_API 0030 #include "unicode/localpointer.h" 0031 #endif // U_SHOW_CPLUSPLUS_API 0032 0033 /** 0034 * \file 0035 * \brief C API: Internationalizing Domain Names in Applications (IDNA) 0036 * 0037 * IDNA2008 is implemented according to UTS #46, see the IDNA C++ class in idna.h. 0038 * 0039 * The C API functions which do take a UIDNA * service object pointer 0040 * implement UTS #46 and IDNA2008. 0041 * 0042 * IDNA2003 is obsolete. 0043 * The C API functions which do not take a service object pointer 0044 * implement IDNA2003. They are all deprecated. 0045 */ 0046 0047 /* 0048 * IDNA option bit set values. 0049 */ 0050 enum { 0051 /** 0052 * Default options value: None of the other options are set. 0053 * For use in static worker and factory methods. 0054 * @stable ICU 2.6 0055 */ 0056 UIDNA_DEFAULT=0, 0057 #ifndef U_HIDE_DEPRECATED_API 0058 /** 0059 * Option to allow unassigned code points in domain names and labels. 0060 * For use in static worker and factory methods. 0061 * <p>This option is ignored by the UTS46 implementation. 0062 * (UTS #46 disallows unassigned code points.) 0063 * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. 0064 */ 0065 UIDNA_ALLOW_UNASSIGNED=1, 0066 #endif /* U_HIDE_DEPRECATED_API */ 0067 /** 0068 * Option to check whether the input conforms to the STD3 ASCII rules, 0069 * for example the restriction of labels to LDH characters 0070 * (ASCII Letters, Digits and Hyphen-Minus). 0071 * For use in static worker and factory methods. 0072 * @stable ICU 2.6 0073 */ 0074 UIDNA_USE_STD3_RULES=2, 0075 /** 0076 * IDNA option to check for whether the input conforms to the BiDi rules. 0077 * For use in static worker and factory methods. 0078 * <p>This option is ignored by the IDNA2003 implementation. 0079 * (IDNA2003 always performs a BiDi check.) 0080 * @stable ICU 4.6 0081 */ 0082 UIDNA_CHECK_BIDI=4, 0083 /** 0084 * IDNA option to check for whether the input conforms to the CONTEXTJ rules. 0085 * For use in static worker and factory methods. 0086 * <p>This option is ignored by the IDNA2003 implementation. 0087 * (The CONTEXTJ check is new in IDNA2008.) 0088 * @stable ICU 4.6 0089 */ 0090 UIDNA_CHECK_CONTEXTJ=8, 0091 /** 0092 * IDNA option for nontransitional processing in ToASCII(). 0093 * For use in static worker and factory methods. 0094 * <p>By default, ToASCII() uses transitional processing. 0095 * <p>This option is ignored by the IDNA2003 implementation. 0096 * (This is only relevant for compatibility of newer IDNA implementations with IDNA2003.) 0097 * @stable ICU 4.6 0098 */ 0099 UIDNA_NONTRANSITIONAL_TO_ASCII=0x10, 0100 /** 0101 * IDNA option for nontransitional processing in ToUnicode(). 0102 * For use in static worker and factory methods. 0103 * <p>By default, ToUnicode() uses transitional processing. 0104 * <p>This option is ignored by the IDNA2003 implementation. 0105 * (This is only relevant for compatibility of newer IDNA implementations with IDNA2003.) 0106 * @stable ICU 4.6 0107 */ 0108 UIDNA_NONTRANSITIONAL_TO_UNICODE=0x20, 0109 /** 0110 * IDNA option to check for whether the input conforms to the CONTEXTO rules. 0111 * For use in static worker and factory methods. 0112 * <p>This option is ignored by the IDNA2003 implementation. 0113 * (The CONTEXTO check is new in IDNA2008.) 0114 * <p>This is for use by registries for IDNA2008 conformance. 0115 * UTS #46 does not require the CONTEXTO check. 0116 * @stable ICU 49 0117 */ 0118 UIDNA_CHECK_CONTEXTO=0x40 0119 }; 0120 0121 /** 0122 * Opaque C service object type for the new IDNA API. 0123 * @stable ICU 4.6 0124 */ 0125 struct UIDNA; 0126 typedef struct UIDNA UIDNA; /**< C typedef for struct UIDNA. @stable ICU 4.6 */ 0127 0128 /** 0129 * Returns a UIDNA instance which implements UTS #46. 0130 * Returns an unmodifiable instance, owned by the caller. 0131 * Cache it for multiple operations, and uidna_close() it when done. 0132 * The instance is thread-safe, that is, it can be used concurrently. 0133 * 0134 * For details about the UTS #46 implementation see the IDNA C++ class in idna.h. 0135 * 0136 * @param options Bit set to modify the processing and error checking. 0137 * See option bit set values in uidna.h. 0138 * @param pErrorCode Standard ICU error code. Its input value must 0139 * pass the U_SUCCESS() test, or else the function returns 0140 * immediately. Check for U_FAILURE() on output or use with 0141 * function chaining. (See User Guide for details.) 0142 * @return the UTS #46 UIDNA instance, if successful 0143 * @stable ICU 4.6 0144 */ 0145 U_CAPI UIDNA * U_EXPORT2 0146 uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode); 0147 0148 /** 0149 * Closes a UIDNA instance. 0150 * @param idna UIDNA instance to be closed 0151 * @stable ICU 4.6 0152 */ 0153 U_CAPI void U_EXPORT2 0154 uidna_close(UIDNA *idna); 0155 0156 #if U_SHOW_CPLUSPLUS_API 0157 0158 U_NAMESPACE_BEGIN 0159 0160 /** 0161 * \class LocalUIDNAPointer 0162 * "Smart pointer" class, closes a UIDNA via uidna_close(). 0163 * For most methods see the LocalPointerBase base class. 0164 * 0165 * @see LocalPointerBase 0166 * @see LocalPointer 0167 * @stable ICU 4.6 0168 */ 0169 U_DEFINE_LOCAL_OPEN_POINTER(LocalUIDNAPointer, UIDNA, uidna_close); 0170 0171 U_NAMESPACE_END 0172 0173 #endif 0174 0175 /** 0176 * Output container for IDNA processing errors. 0177 * Initialize with UIDNA_INFO_INITIALIZER: 0178 * \code 0179 * UIDNAInfo info = UIDNA_INFO_INITIALIZER; 0180 * int32_t length = uidna_nameToASCII(..., &info, &errorCode); 0181 * if(U_SUCCESS(errorCode) && info.errors!=0) { ... } 0182 * \endcode 0183 * @stable ICU 4.6 0184 */ 0185 typedef struct UIDNAInfo { 0186 /** sizeof(UIDNAInfo) @stable ICU 4.6 */ 0187 int16_t size; 0188 /** 0189 * Set to true if transitional and nontransitional processing produce different results. 0190 * For details see C++ IDNAInfo::isTransitionalDifferent(). 0191 * @stable ICU 4.6 0192 */ 0193 UBool isTransitionalDifferent; 0194 UBool reservedB3; /**< Reserved field, do not use. @internal */ 0195 /** 0196 * Bit set indicating IDNA processing errors. 0 if no errors. 0197 * See UIDNA_ERROR_... constants. 0198 * @stable ICU 4.6 0199 */ 0200 uint32_t errors; 0201 int32_t reservedI2; /**< Reserved field, do not use. @internal */ 0202 int32_t reservedI3; /**< Reserved field, do not use. @internal */ 0203 } UIDNAInfo; 0204 0205 /** 0206 * Static initializer for a UIDNAInfo struct. 0207 * @stable ICU 4.6 0208 */ 0209 #define UIDNA_INFO_INITIALIZER { \ 0210 (int16_t)sizeof(UIDNAInfo), \ 0211 false, false, \ 0212 0, 0, 0 } 0213 0214 /** 0215 * Converts a single domain name label into its ASCII form for DNS lookup. 0216 * If any processing step fails, then pInfo->errors will be non-zero and 0217 * the result might not be an ASCII string. 0218 * The label might be modified according to the types of errors. 0219 * Labels with severe errors will be left in (or turned into) their Unicode form. 0220 * 0221 * The UErrorCode indicates an error only in exceptional cases, 0222 * such as a U_MEMORY_ALLOCATION_ERROR. 0223 * 0224 * @param idna UIDNA instance 0225 * @param label Input domain name label 0226 * @param length Label length, or -1 if NUL-terminated 0227 * @param dest Destination string buffer 0228 * @param capacity Destination buffer capacity 0229 * @param pInfo Output container of IDNA processing details. 0230 * @param pErrorCode Standard ICU error code. Its input value must 0231 * pass the U_SUCCESS() test, or else the function returns 0232 * immediately. Check for U_FAILURE() on output or use with 0233 * function chaining. (See User Guide for details.) 0234 * @return destination string length 0235 * @stable ICU 4.6 0236 */ 0237 U_CAPI int32_t U_EXPORT2 0238 uidna_labelToASCII(const UIDNA *idna, 0239 const UChar *label, int32_t length, 0240 UChar *dest, int32_t capacity, 0241 UIDNAInfo *pInfo, UErrorCode *pErrorCode); 0242 0243 /** 0244 * Converts a single domain name label into its Unicode form for human-readable display. 0245 * If any processing step fails, then pInfo->errors will be non-zero. 0246 * The label might be modified according to the types of errors. 0247 * 0248 * The UErrorCode indicates an error only in exceptional cases, 0249 * such as a U_MEMORY_ALLOCATION_ERROR. 0250 * 0251 * @param idna UIDNA instance 0252 * @param label Input domain name label 0253 * @param length Label length, or -1 if NUL-terminated 0254 * @param dest Destination string buffer 0255 * @param capacity Destination buffer capacity 0256 * @param pInfo Output container of IDNA processing details. 0257 * @param pErrorCode Standard ICU error code. Its input value must 0258 * pass the U_SUCCESS() test, or else the function returns 0259 * immediately. Check for U_FAILURE() on output or use with 0260 * function chaining. (See User Guide for details.) 0261 * @return destination string length 0262 * @stable ICU 4.6 0263 */ 0264 U_CAPI int32_t U_EXPORT2 0265 uidna_labelToUnicode(const UIDNA *idna, 0266 const UChar *label, int32_t length, 0267 UChar *dest, int32_t capacity, 0268 UIDNAInfo *pInfo, UErrorCode *pErrorCode); 0269 0270 /** 0271 * Converts a whole domain name into its ASCII form for DNS lookup. 0272 * If any processing step fails, then pInfo->errors will be non-zero and 0273 * the result might not be an ASCII string. 0274 * The domain name might be modified according to the types of errors. 0275 * Labels with severe errors will be left in (or turned into) their Unicode form. 0276 * 0277 * The UErrorCode indicates an error only in exceptional cases, 0278 * such as a U_MEMORY_ALLOCATION_ERROR. 0279 * 0280 * @param idna UIDNA instance 0281 * @param name Input domain name 0282 * @param length Domain name length, or -1 if NUL-terminated 0283 * @param dest Destination string buffer 0284 * @param capacity Destination buffer capacity 0285 * @param pInfo Output container of IDNA processing details. 0286 * @param pErrorCode Standard ICU error code. Its input value must 0287 * pass the U_SUCCESS() test, or else the function returns 0288 * immediately. Check for U_FAILURE() on output or use with 0289 * function chaining. (See User Guide for details.) 0290 * @return destination string length 0291 * @stable ICU 4.6 0292 */ 0293 U_CAPI int32_t U_EXPORT2 0294 uidna_nameToASCII(const UIDNA *idna, 0295 const UChar *name, int32_t length, 0296 UChar *dest, int32_t capacity, 0297 UIDNAInfo *pInfo, UErrorCode *pErrorCode); 0298 0299 /** 0300 * Converts a whole domain name into its Unicode form for human-readable display. 0301 * If any processing step fails, then pInfo->errors will be non-zero. 0302 * The domain name might be modified according to the types of errors. 0303 * 0304 * The UErrorCode indicates an error only in exceptional cases, 0305 * such as a U_MEMORY_ALLOCATION_ERROR. 0306 * 0307 * @param idna UIDNA instance 0308 * @param name Input domain name 0309 * @param length Domain name length, or -1 if NUL-terminated 0310 * @param dest Destination string buffer 0311 * @param capacity Destination buffer capacity 0312 * @param pInfo Output container of IDNA processing details. 0313 * @param pErrorCode Standard ICU error code. Its input value must 0314 * pass the U_SUCCESS() test, or else the function returns 0315 * immediately. Check for U_FAILURE() on output or use with 0316 * function chaining. (See User Guide for details.) 0317 * @return destination string length 0318 * @stable ICU 4.6 0319 */ 0320 U_CAPI int32_t U_EXPORT2 0321 uidna_nameToUnicode(const UIDNA *idna, 0322 const UChar *name, int32_t length, 0323 UChar *dest, int32_t capacity, 0324 UIDNAInfo *pInfo, UErrorCode *pErrorCode); 0325 0326 /* UTF-8 versions of the processing methods --------------------------------- */ 0327 0328 /** 0329 * Converts a single domain name label into its ASCII form for DNS lookup. 0330 * UTF-8 version of uidna_labelToASCII(), same behavior. 0331 * 0332 * @param idna UIDNA instance 0333 * @param label Input domain name label 0334 * @param length Label length, or -1 if NUL-terminated 0335 * @param dest Destination string buffer 0336 * @param capacity Destination buffer capacity 0337 * @param pInfo Output container of IDNA processing details. 0338 * @param pErrorCode Standard ICU error code. Its input value must 0339 * pass the U_SUCCESS() test, or else the function returns 0340 * immediately. Check for U_FAILURE() on output or use with 0341 * function chaining. (See User Guide for details.) 0342 * @return destination string length 0343 * @stable ICU 4.6 0344 */ 0345 U_CAPI int32_t U_EXPORT2 0346 uidna_labelToASCII_UTF8(const UIDNA *idna, 0347 const char *label, int32_t length, 0348 char *dest, int32_t capacity, 0349 UIDNAInfo *pInfo, UErrorCode *pErrorCode); 0350 0351 /** 0352 * Converts a single domain name label into its Unicode form for human-readable display. 0353 * UTF-8 version of uidna_labelToUnicode(), same behavior. 0354 * 0355 * @param idna UIDNA instance 0356 * @param label Input domain name label 0357 * @param length Label length, or -1 if NUL-terminated 0358 * @param dest Destination string buffer 0359 * @param capacity Destination buffer capacity 0360 * @param pInfo Output container of IDNA processing details. 0361 * @param pErrorCode Standard ICU error code. Its input value must 0362 * pass the U_SUCCESS() test, or else the function returns 0363 * immediately. Check for U_FAILURE() on output or use with 0364 * function chaining. (See User Guide for details.) 0365 * @return destination string length 0366 * @stable ICU 4.6 0367 */ 0368 U_CAPI int32_t U_EXPORT2 0369 uidna_labelToUnicodeUTF8(const UIDNA *idna, 0370 const char *label, int32_t length, 0371 char *dest, int32_t capacity, 0372 UIDNAInfo *pInfo, UErrorCode *pErrorCode); 0373 0374 /** 0375 * Converts a whole domain name into its ASCII form for DNS lookup. 0376 * UTF-8 version of uidna_nameToASCII(), same behavior. 0377 * 0378 * @param idna UIDNA instance 0379 * @param name Input domain name 0380 * @param length Domain name length, or -1 if NUL-terminated 0381 * @param dest Destination string buffer 0382 * @param capacity Destination buffer capacity 0383 * @param pInfo Output container of IDNA processing details. 0384 * @param pErrorCode Standard ICU error code. Its input value must 0385 * pass the U_SUCCESS() test, or else the function returns 0386 * immediately. Check for U_FAILURE() on output or use with 0387 * function chaining. (See User Guide for details.) 0388 * @return destination string length 0389 * @stable ICU 4.6 0390 */ 0391 U_CAPI int32_t U_EXPORT2 0392 uidna_nameToASCII_UTF8(const UIDNA *idna, 0393 const char *name, int32_t length, 0394 char *dest, int32_t capacity, 0395 UIDNAInfo *pInfo, UErrorCode *pErrorCode); 0396 0397 /** 0398 * Converts a whole domain name into its Unicode form for human-readable display. 0399 * UTF-8 version of uidna_nameToUnicode(), same behavior. 0400 * 0401 * @param idna UIDNA instance 0402 * @param name Input domain name 0403 * @param length Domain name length, or -1 if NUL-terminated 0404 * @param dest Destination string buffer 0405 * @param capacity Destination buffer capacity 0406 * @param pInfo Output container of IDNA processing details. 0407 * @param pErrorCode Standard ICU error code. Its input value must 0408 * pass the U_SUCCESS() test, or else the function returns 0409 * immediately. Check for U_FAILURE() on output or use with 0410 * function chaining. (See User Guide for details.) 0411 * @return destination string length 0412 * @stable ICU 4.6 0413 */ 0414 U_CAPI int32_t U_EXPORT2 0415 uidna_nameToUnicodeUTF8(const UIDNA *idna, 0416 const char *name, int32_t length, 0417 char *dest, int32_t capacity, 0418 UIDNAInfo *pInfo, UErrorCode *pErrorCode); 0419 0420 /* 0421 * IDNA error bit set values. 0422 * When a domain name or label fails a processing step or does not meet the 0423 * validity criteria, then one or more of these error bits are set. 0424 */ 0425 enum { 0426 /** 0427 * A non-final domain name label (or the whole domain name) is empty. 0428 * @stable ICU 4.6 0429 */ 0430 UIDNA_ERROR_EMPTY_LABEL=1, 0431 /** 0432 * A domain name label is longer than 63 bytes. 0433 * (See STD13/RFC1034 3.1. Name space specifications and terminology.) 0434 * This is only checked in ToASCII operations, and only if the output label is all-ASCII. 0435 * @stable ICU 4.6 0436 */ 0437 UIDNA_ERROR_LABEL_TOO_LONG=2, 0438 /** 0439 * A domain name is longer than 255 bytes in its storage form. 0440 * (See STD13/RFC1034 3.1. Name space specifications and terminology.) 0441 * This is only checked in ToASCII operations, and only if the output domain name is all-ASCII. 0442 * @stable ICU 4.6 0443 */ 0444 UIDNA_ERROR_DOMAIN_NAME_TOO_LONG=4, 0445 /** 0446 * A label starts with a hyphen-minus ('-'). 0447 * @stable ICU 4.6 0448 */ 0449 UIDNA_ERROR_LEADING_HYPHEN=8, 0450 /** 0451 * A label ends with a hyphen-minus ('-'). 0452 * @stable ICU 4.6 0453 */ 0454 UIDNA_ERROR_TRAILING_HYPHEN=0x10, 0455 /** 0456 * A label contains hyphen-minus ('-') in the third and fourth positions. 0457 * @stable ICU 4.6 0458 */ 0459 UIDNA_ERROR_HYPHEN_3_4=0x20, 0460 /** 0461 * A label starts with a combining mark. 0462 * @stable ICU 4.6 0463 */ 0464 UIDNA_ERROR_LEADING_COMBINING_MARK=0x40, 0465 /** 0466 * A label or domain name contains disallowed characters. 0467 * @stable ICU 4.6 0468 */ 0469 UIDNA_ERROR_DISALLOWED=0x80, 0470 /** 0471 * A label starts with "xn--" but does not contain valid Punycode. 0472 * That is, an xn-- label failed Punycode decoding. 0473 * @stable ICU 4.6 0474 */ 0475 UIDNA_ERROR_PUNYCODE=0x100, 0476 /** 0477 * A label contains a dot=full stop. 0478 * This can occur in an input string for a single-label function. 0479 * @stable ICU 4.6 0480 */ 0481 UIDNA_ERROR_LABEL_HAS_DOT=0x200, 0482 /** 0483 * An ACE label does not contain a valid label string. 0484 * The label was successfully ACE (Punycode) decoded but the resulting 0485 * string had severe validation errors. For example, 0486 * it might contain characters that are not allowed in ACE labels, 0487 * or it might not be normalized. 0488 * @stable ICU 4.6 0489 */ 0490 UIDNA_ERROR_INVALID_ACE_LABEL=0x400, 0491 /** 0492 * A label does not meet the IDNA BiDi requirements (for right-to-left characters). 0493 * @stable ICU 4.6 0494 */ 0495 UIDNA_ERROR_BIDI=0x800, 0496 /** 0497 * A label does not meet the IDNA CONTEXTJ requirements. 0498 * @stable ICU 4.6 0499 */ 0500 UIDNA_ERROR_CONTEXTJ=0x1000, 0501 /** 0502 * A label does not meet the IDNA CONTEXTO requirements for punctuation characters. 0503 * Some punctuation characters "Would otherwise have been DISALLOWED" 0504 * but are allowed in certain contexts. (RFC 5892) 0505 * @stable ICU 49 0506 */ 0507 UIDNA_ERROR_CONTEXTO_PUNCTUATION=0x2000, 0508 /** 0509 * A label does not meet the IDNA CONTEXTO requirements for digits. 0510 * Arabic-Indic Digits (U+066x) must not be mixed with Extended Arabic-Indic Digits (U+06Fx). 0511 * @stable ICU 49 0512 */ 0513 UIDNA_ERROR_CONTEXTO_DIGITS=0x4000 0514 }; 0515 0516 #ifndef U_HIDE_DEPRECATED_API 0517 0518 /* IDNA2003 API ------------------------------------------------------------- */ 0519 0520 /** 0521 * IDNA2003: This function implements the ToASCII operation as defined in the IDNA RFC. 0522 * This operation is done on <b>single labels</b> before sending it to something that expects 0523 * ASCII names. A label is an individual part of a domain name. Labels are usually 0524 * separated by dots; e.g. "www.example.com" is composed of 3 labels "www","example", and "com". 0525 * 0526 * IDNA2003 API Overview: 0527 * 0528 * The uidna_ API implements the IDNA protocol as defined in the IDNA RFC 0529 * (http://www.ietf.org/rfc/rfc3490.txt). 0530 * The RFC defines 2 operations: ToASCII and ToUnicode. Domain name labels 0531 * containing non-ASCII code points are processed by the 0532 * ToASCII operation before passing it to resolver libraries. Domain names 0533 * that are obtained from resolver libraries are processed by the 0534 * ToUnicode operation before displaying the domain name to the user. 0535 * IDNA requires that implementations process input strings with Nameprep 0536 * (http://www.ietf.org/rfc/rfc3491.txt), 0537 * which is a profile of Stringprep (http://www.ietf.org/rfc/rfc3454.txt), 0538 * and then with Punycode (http://www.ietf.org/rfc/rfc3492.txt). 0539 * Implementations of IDNA MUST fully implement Nameprep and Punycode; 0540 * neither Nameprep nor Punycode are optional. 0541 * The input and output of ToASCII and ToUnicode operations are Unicode 0542 * and are designed to be chainable, i.e., applying ToASCII or ToUnicode operations 0543 * multiple times to an input string will yield the same result as applying the operation 0544 * once. 0545 * ToUnicode(ToUnicode(ToUnicode...(ToUnicode(string)))) == ToUnicode(string) 0546 * ToASCII(ToASCII(ToASCII...(ToASCII(string))) == ToASCII(string). 0547 * 0548 * @param src Input UChar array containing label in Unicode. 0549 * @param srcLength Number of UChars in src, or -1 if NUL-terminated. 0550 * @param dest Output UChar array with ASCII (ACE encoded) label. 0551 * @param destCapacity Size of dest. 0552 * @param options A bit set of options: 0553 * 0554 * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points 0555 * and do not use STD3 ASCII rules 0556 * If unassigned code points are found the operation fails with 0557 * U_UNASSIGNED_ERROR error code. 0558 * 0559 * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations 0560 * If this option is set, the unassigned code points are in the input 0561 * are treated as normal Unicode code points. 0562 * 0563 * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions 0564 * If this option is set and the input does not satisfy STD3 rules, 0565 * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR 0566 * 0567 * @param parseError Pointer to UParseError struct to receive information on position 0568 * of error if an error is encountered. Can be NULL. 0569 * @param status ICU in/out error code parameter. 0570 * U_INVALID_CHAR_FOUND if src contains 0571 * unmatched single surrogates. 0572 * U_INDEX_OUTOFBOUNDS_ERROR if src contains 0573 * too many code points. 0574 * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough 0575 * @return The length of the result string, if successful - or in case of a buffer overflow, 0576 * in which case it will be greater than destCapacity. 0577 * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. 0578 */ 0579 U_DEPRECATED int32_t U_EXPORT2 0580 uidna_toASCII(const UChar* src, int32_t srcLength, 0581 UChar* dest, int32_t destCapacity, 0582 int32_t options, 0583 UParseError* parseError, 0584 UErrorCode* status); 0585 0586 0587 /** 0588 * IDNA2003: This function implements the ToUnicode operation as defined in the IDNA RFC. 0589 * This operation is done on <b>single labels</b> before sending it to something that expects 0590 * Unicode names. A label is an individual part of a domain name. Labels are usually 0591 * separated by dots; for e.g. "www.example.com" is composed of 3 labels "www","example", and "com". 0592 * 0593 * @param src Input UChar array containing ASCII (ACE encoded) label. 0594 * @param srcLength Number of UChars in src, or -1 if NUL-terminated. 0595 * @param dest Output Converted UChar array containing Unicode equivalent of label. 0596 * @param destCapacity Size of dest. 0597 * @param options A bit set of options: 0598 * 0599 * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points 0600 * and do not use STD3 ASCII rules 0601 * If unassigned code points are found the operation fails with 0602 * U_UNASSIGNED_ERROR error code. 0603 * 0604 * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations 0605 * If this option is set, the unassigned code points are in the input 0606 * are treated as normal Unicode code points. <b> Note: </b> This option is 0607 * required on toUnicode operation because the RFC mandates 0608 * verification of decoded ACE input by applying toASCII and comparing 0609 * its output with source 0610 * 0611 * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions 0612 * If this option is set and the input does not satisfy STD3 rules, 0613 * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR 0614 * 0615 * @param parseError Pointer to UParseError struct to receive information on position 0616 * of error if an error is encountered. Can be NULL. 0617 * @param status ICU in/out error code parameter. 0618 * U_INVALID_CHAR_FOUND if src contains 0619 * unmatched single surrogates. 0620 * U_INDEX_OUTOFBOUNDS_ERROR if src contains 0621 * too many code points. 0622 * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough 0623 * @return The length of the result string, if successful - or in case of a buffer overflow, 0624 * in which case it will be greater than destCapacity. 0625 * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. 0626 */ 0627 U_DEPRECATED int32_t U_EXPORT2 0628 uidna_toUnicode(const UChar* src, int32_t srcLength, 0629 UChar* dest, int32_t destCapacity, 0630 int32_t options, 0631 UParseError* parseError, 0632 UErrorCode* status); 0633 0634 0635 /** 0636 * IDNA2003: Convenience function that implements the IDNToASCII operation as defined in the IDNA RFC. 0637 * This operation is done on complete domain names, e.g: "www.example.com". 0638 * It is important to note that this operation can fail. If it fails, then the input 0639 * domain name cannot be used as an Internationalized Domain Name and the application 0640 * should have methods defined to deal with the failure. 0641 * 0642 * <b>Note:</b> IDNA RFC specifies that a conformant application should divide a domain name 0643 * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, 0644 * and then convert. This function does not offer that level of granularity. The options once 0645 * set will apply to all labels in the domain name 0646 * 0647 * @param src Input UChar array containing IDN in Unicode. 0648 * @param srcLength Number of UChars in src, or -1 if NUL-terminated. 0649 * @param dest Output UChar array with ASCII (ACE encoded) IDN. 0650 * @param destCapacity Size of dest. 0651 * @param options A bit set of options: 0652 * 0653 * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points 0654 * and do not use STD3 ASCII rules 0655 * If unassigned code points are found the operation fails with 0656 * U_UNASSIGNED_CODE_POINT_FOUND error code. 0657 * 0658 * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations 0659 * If this option is set, the unassigned code points are in the input 0660 * are treated as normal Unicode code points. 0661 * 0662 * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions 0663 * If this option is set and the input does not satisfy STD3 rules, 0664 * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR 0665 * 0666 * @param parseError Pointer to UParseError struct to receive information on position 0667 * of error if an error is encountered. Can be NULL. 0668 * @param status ICU in/out error code parameter. 0669 * U_INVALID_CHAR_FOUND if src contains 0670 * unmatched single surrogates. 0671 * U_INDEX_OUTOFBOUNDS_ERROR if src contains 0672 * too many code points. 0673 * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough 0674 * @return The length of the result string, if successful - or in case of a buffer overflow, 0675 * in which case it will be greater than destCapacity. 0676 * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. 0677 */ 0678 U_DEPRECATED int32_t U_EXPORT2 0679 uidna_IDNToASCII( const UChar* src, int32_t srcLength, 0680 UChar* dest, int32_t destCapacity, 0681 int32_t options, 0682 UParseError* parseError, 0683 UErrorCode* status); 0684 0685 /** 0686 * IDNA2003: Convenience function that implements the IDNToUnicode operation as defined in the IDNA RFC. 0687 * This operation is done on complete domain names, e.g: "www.example.com". 0688 * 0689 * <b>Note:</b> IDNA RFC specifies that a conformant application should divide a domain name 0690 * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, 0691 * and then convert. This function does not offer that level of granularity. The options once 0692 * set will apply to all labels in the domain name 0693 * 0694 * @param src Input UChar array containing IDN in ASCII (ACE encoded) form. 0695 * @param srcLength Number of UChars in src, or -1 if NUL-terminated. 0696 * @param dest Output UChar array containing Unicode equivalent of source IDN. 0697 * @param destCapacity Size of dest. 0698 * @param options A bit set of options: 0699 * 0700 * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points 0701 * and do not use STD3 ASCII rules 0702 * If unassigned code points are found the operation fails with 0703 * U_UNASSIGNED_CODE_POINT_FOUND error code. 0704 * 0705 * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations 0706 * If this option is set, the unassigned code points are in the input 0707 * are treated as normal Unicode code points. 0708 * 0709 * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions 0710 * If this option is set and the input does not satisfy STD3 rules, 0711 * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR 0712 * 0713 * @param parseError Pointer to UParseError struct to receive information on position 0714 * of error if an error is encountered. Can be NULL. 0715 * @param status ICU in/out error code parameter. 0716 * U_INVALID_CHAR_FOUND if src contains 0717 * unmatched single surrogates. 0718 * U_INDEX_OUTOFBOUNDS_ERROR if src contains 0719 * too many code points. 0720 * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough 0721 * @return The length of the result string, if successful - or in case of a buffer overflow, 0722 * in which case it will be greater than destCapacity. 0723 * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. 0724 */ 0725 U_DEPRECATED int32_t U_EXPORT2 0726 uidna_IDNToUnicode( const UChar* src, int32_t srcLength, 0727 UChar* dest, int32_t destCapacity, 0728 int32_t options, 0729 UParseError* parseError, 0730 UErrorCode* status); 0731 0732 /** 0733 * IDNA2003: Compare two IDN strings for equivalence. 0734 * This function splits the domain names into labels and compares them. 0735 * According to IDN RFC, whenever two labels are compared, they are 0736 * considered equal if and only if their ASCII forms (obtained by 0737 * applying toASCII) match using an case-insensitive ASCII comparison. 0738 * Two domain names are considered a match if and only if all labels 0739 * match regardless of whether label separators match. 0740 * 0741 * @param s1 First source string. 0742 * @param length1 Length of first source string, or -1 if NUL-terminated. 0743 * 0744 * @param s2 Second source string. 0745 * @param length2 Length of second source string, or -1 if NUL-terminated. 0746 * @param options A bit set of options: 0747 * 0748 * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points 0749 * and do not use STD3 ASCII rules 0750 * If unassigned code points are found the operation fails with 0751 * U_UNASSIGNED_CODE_POINT_FOUND error code. 0752 * 0753 * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations 0754 * If this option is set, the unassigned code points are in the input 0755 * are treated as normal Unicode code points. 0756 * 0757 * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions 0758 * If this option is set and the input does not satisfy STD3 rules, 0759 * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR 0760 * 0761 * @param status ICU error code in/out parameter. 0762 * Must fulfill U_SUCCESS before the function call. 0763 * @return <0 or 0 or >0 as usual for string comparisons 0764 * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. 0765 */ 0766 U_DEPRECATED int32_t U_EXPORT2 0767 uidna_compare( const UChar *s1, int32_t length1, 0768 const UChar *s2, int32_t length2, 0769 int32_t options, 0770 UErrorCode* status); 0771 0772 #endif /* U_HIDE_DEPRECATED_API */ 0773 0774 #endif /* #if !UCONFIG_NO_IDNA */ 0775 0776 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |