jpayne@69: // © 2016 and later: Unicode, Inc. and others. jpayne@69: // License & terms of use: http://www.unicode.org/copyright.html jpayne@69: /* jpayne@69: ******************************************************************************* jpayne@69: * jpayne@69: * Copyright (C) 2003-2014, International Business Machines jpayne@69: * Corporation and others. All Rights Reserved. jpayne@69: * jpayne@69: ******************************************************************************* jpayne@69: * file name: uidna.h jpayne@69: * encoding: UTF-8 jpayne@69: * tab size: 8 (not used) jpayne@69: * indentation:4 jpayne@69: * jpayne@69: * created on: 2003feb1 jpayne@69: * created by: Ram Viswanadha jpayne@69: */ jpayne@69: jpayne@69: #ifndef __UIDNA_H__ jpayne@69: #define __UIDNA_H__ jpayne@69: jpayne@69: #include "unicode/utypes.h" jpayne@69: jpayne@69: #if !UCONFIG_NO_IDNA jpayne@69: jpayne@69: #include "unicode/localpointer.h" jpayne@69: #include "unicode/parseerr.h" jpayne@69: jpayne@69: /** jpayne@69: * \file jpayne@69: * \brief C API: Internationalizing Domain Names in Applications (IDNA) jpayne@69: * jpayne@69: * IDNA2008 is implemented according to UTS #46, see the IDNA C++ class in idna.h. jpayne@69: * jpayne@69: * The C API functions which do take a UIDNA * service object pointer jpayne@69: * implement UTS #46 and IDNA2008. jpayne@69: * jpayne@69: * IDNA2003 is obsolete. jpayne@69: * The C API functions which do not take a service object pointer jpayne@69: * implement IDNA2003. They are all deprecated. jpayne@69: */ jpayne@69: jpayne@69: /* jpayne@69: * IDNA option bit set values. jpayne@69: */ jpayne@69: enum { jpayne@69: /** jpayne@69: * Default options value: None of the other options are set. jpayne@69: * For use in static worker and factory methods. jpayne@69: * @stable ICU 2.6 jpayne@69: */ jpayne@69: UIDNA_DEFAULT=0, jpayne@69: #ifndef U_HIDE_DEPRECATED_API jpayne@69: /** jpayne@69: * Option to allow unassigned code points in domain names and labels. jpayne@69: * For use in static worker and factory methods. jpayne@69: *
This option is ignored by the UTS46 implementation. jpayne@69: * (UTS #46 disallows unassigned code points.) jpayne@69: * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. jpayne@69: */ jpayne@69: UIDNA_ALLOW_UNASSIGNED=1, jpayne@69: #endif /* U_HIDE_DEPRECATED_API */ jpayne@69: /** jpayne@69: * Option to check whether the input conforms to the STD3 ASCII rules, jpayne@69: * for example the restriction of labels to LDH characters jpayne@69: * (ASCII Letters, Digits and Hyphen-Minus). jpayne@69: * For use in static worker and factory methods. jpayne@69: * @stable ICU 2.6 jpayne@69: */ jpayne@69: UIDNA_USE_STD3_RULES=2, jpayne@69: /** jpayne@69: * IDNA option to check for whether the input conforms to the BiDi rules. jpayne@69: * For use in static worker and factory methods. jpayne@69: *
This option is ignored by the IDNA2003 implementation. jpayne@69: * (IDNA2003 always performs a BiDi check.) jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_CHECK_BIDI=4, jpayne@69: /** jpayne@69: * IDNA option to check for whether the input conforms to the CONTEXTJ rules. jpayne@69: * For use in static worker and factory methods. jpayne@69: *
This option is ignored by the IDNA2003 implementation. jpayne@69: * (The CONTEXTJ check is new in IDNA2008.) jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_CHECK_CONTEXTJ=8, jpayne@69: /** jpayne@69: * IDNA option for nontransitional processing in ToASCII(). jpayne@69: * For use in static worker and factory methods. jpayne@69: *
By default, ToASCII() uses transitional processing. jpayne@69: *
This option is ignored by the IDNA2003 implementation. jpayne@69: * (This is only relevant for compatibility of newer IDNA implementations with IDNA2003.) jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_NONTRANSITIONAL_TO_ASCII=0x10, jpayne@69: /** jpayne@69: * IDNA option for nontransitional processing in ToUnicode(). jpayne@69: * For use in static worker and factory methods. jpayne@69: *
By default, ToUnicode() uses transitional processing. jpayne@69: *
This option is ignored by the IDNA2003 implementation. jpayne@69: * (This is only relevant for compatibility of newer IDNA implementations with IDNA2003.) jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_NONTRANSITIONAL_TO_UNICODE=0x20, jpayne@69: /** jpayne@69: * IDNA option to check for whether the input conforms to the CONTEXTO rules. jpayne@69: * For use in static worker and factory methods. jpayne@69: *
This option is ignored by the IDNA2003 implementation. jpayne@69: * (The CONTEXTO check is new in IDNA2008.) jpayne@69: *
This is for use by registries for IDNA2008 conformance. jpayne@69: * UTS #46 does not require the CONTEXTO check. jpayne@69: * @stable ICU 49 jpayne@69: */ jpayne@69: UIDNA_CHECK_CONTEXTO=0x40 jpayne@69: }; jpayne@69: jpayne@69: /** jpayne@69: * Opaque C service object type for the new IDNA API. jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: struct UIDNA; jpayne@69: typedef struct UIDNA UIDNA; /**< C typedef for struct UIDNA. @stable ICU 4.6 */ jpayne@69: jpayne@69: /** jpayne@69: * Returns a UIDNA instance which implements UTS #46. jpayne@69: * Returns an unmodifiable instance, owned by the caller. jpayne@69: * Cache it for multiple operations, and uidna_close() it when done. jpayne@69: * The instance is thread-safe, that is, it can be used concurrently. jpayne@69: * jpayne@69: * For details about the UTS #46 implementation see the IDNA C++ class in idna.h. jpayne@69: * jpayne@69: * @param options Bit set to modify the processing and error checking. jpayne@69: * See option bit set values in uidna.h. jpayne@69: * @param pErrorCode Standard ICU error code. Its input value must jpayne@69: * pass the U_SUCCESS() test, or else the function returns jpayne@69: * immediately. Check for U_FAILURE() on output or use with jpayne@69: * function chaining. (See User Guide for details.) jpayne@69: * @return the UTS #46 UIDNA instance, if successful jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE UIDNA * U_EXPORT2 jpayne@69: uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode); jpayne@69: jpayne@69: /** jpayne@69: * Closes a UIDNA instance. jpayne@69: * @param idna UIDNA instance to be closed jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE void U_EXPORT2 jpayne@69: uidna_close(UIDNA *idna); jpayne@69: jpayne@69: #if U_SHOW_CPLUSPLUS_API jpayne@69: jpayne@69: U_NAMESPACE_BEGIN jpayne@69: jpayne@69: /** jpayne@69: * \class LocalUIDNAPointer jpayne@69: * "Smart pointer" class, closes a UIDNA via uidna_close(). jpayne@69: * For most methods see the LocalPointerBase base class. jpayne@69: * jpayne@69: * @see LocalPointerBase jpayne@69: * @see LocalPointer jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_DEFINE_LOCAL_OPEN_POINTER(LocalUIDNAPointer, UIDNA, uidna_close); jpayne@69: jpayne@69: U_NAMESPACE_END jpayne@69: jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * Output container for IDNA processing errors. jpayne@69: * Initialize with UIDNA_INFO_INITIALIZER: jpayne@69: * \code jpayne@69: * UIDNAInfo info = UIDNA_INFO_INITIALIZER; jpayne@69: * int32_t length = uidna_nameToASCII(..., &info, &errorCode); jpayne@69: * if(U_SUCCESS(errorCode) && info.errors!=0) { ... } jpayne@69: * \endcode jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: typedef struct UIDNAInfo { jpayne@69: /** sizeof(UIDNAInfo) @stable ICU 4.6 */ jpayne@69: int16_t size; jpayne@69: /** jpayne@69: * Set to TRUE if transitional and nontransitional processing produce different results. jpayne@69: * For details see C++ IDNAInfo::isTransitionalDifferent(). jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UBool isTransitionalDifferent; jpayne@69: UBool reservedB3; /**< Reserved field, do not use. @internal */ jpayne@69: /** jpayne@69: * Bit set indicating IDNA processing errors. 0 if no errors. jpayne@69: * See UIDNA_ERROR_... constants. jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: uint32_t errors; jpayne@69: int32_t reservedI2; /**< Reserved field, do not use. @internal */ jpayne@69: int32_t reservedI3; /**< Reserved field, do not use. @internal */ jpayne@69: } UIDNAInfo; jpayne@69: jpayne@69: /** jpayne@69: * Static initializer for a UIDNAInfo struct. jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: #define UIDNA_INFO_INITIALIZER { \ jpayne@69: (int16_t)sizeof(UIDNAInfo), \ jpayne@69: FALSE, FALSE, \ jpayne@69: 0, 0, 0 } jpayne@69: jpayne@69: /** jpayne@69: * Converts a single domain name label into its ASCII form for DNS lookup. jpayne@69: * If any processing step fails, then pInfo->errors will be non-zero and jpayne@69: * the result might not be an ASCII string. jpayne@69: * The label might be modified according to the types of errors. jpayne@69: * Labels with severe errors will be left in (or turned into) their Unicode form. jpayne@69: * jpayne@69: * The UErrorCode indicates an error only in exceptional cases, jpayne@69: * such as a U_MEMORY_ALLOCATION_ERROR. jpayne@69: * jpayne@69: * @param idna UIDNA instance jpayne@69: * @param label Input domain name label jpayne@69: * @param length Label length, or -1 if NUL-terminated jpayne@69: * @param dest Destination string buffer jpayne@69: * @param capacity Destination buffer capacity jpayne@69: * @param pInfo Output container of IDNA processing details. jpayne@69: * @param pErrorCode Standard ICU error code. Its input value must jpayne@69: * pass the U_SUCCESS() test, or else the function returns jpayne@69: * immediately. Check for U_FAILURE() on output or use with jpayne@69: * function chaining. (See User Guide for details.) jpayne@69: * @return destination string length jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: uidna_labelToASCII(const UIDNA *idna, jpayne@69: const UChar *label, int32_t length, jpayne@69: UChar *dest, int32_t capacity, jpayne@69: UIDNAInfo *pInfo, UErrorCode *pErrorCode); jpayne@69: jpayne@69: /** jpayne@69: * Converts a single domain name label into its Unicode form for human-readable display. jpayne@69: * If any processing step fails, then pInfo->errors will be non-zero. jpayne@69: * The label might be modified according to the types of errors. jpayne@69: * jpayne@69: * The UErrorCode indicates an error only in exceptional cases, jpayne@69: * such as a U_MEMORY_ALLOCATION_ERROR. jpayne@69: * jpayne@69: * @param idna UIDNA instance jpayne@69: * @param label Input domain name label jpayne@69: * @param length Label length, or -1 if NUL-terminated jpayne@69: * @param dest Destination string buffer jpayne@69: * @param capacity Destination buffer capacity jpayne@69: * @param pInfo Output container of IDNA processing details. jpayne@69: * @param pErrorCode Standard ICU error code. Its input value must jpayne@69: * pass the U_SUCCESS() test, or else the function returns jpayne@69: * immediately. Check for U_FAILURE() on output or use with jpayne@69: * function chaining. (See User Guide for details.) jpayne@69: * @return destination string length jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: uidna_labelToUnicode(const UIDNA *idna, jpayne@69: const UChar *label, int32_t length, jpayne@69: UChar *dest, int32_t capacity, jpayne@69: UIDNAInfo *pInfo, UErrorCode *pErrorCode); jpayne@69: jpayne@69: /** jpayne@69: * Converts a whole domain name into its ASCII form for DNS lookup. jpayne@69: * If any processing step fails, then pInfo->errors will be non-zero and jpayne@69: * the result might not be an ASCII string. jpayne@69: * The domain name might be modified according to the types of errors. jpayne@69: * Labels with severe errors will be left in (or turned into) their Unicode form. jpayne@69: * jpayne@69: * The UErrorCode indicates an error only in exceptional cases, jpayne@69: * such as a U_MEMORY_ALLOCATION_ERROR. jpayne@69: * jpayne@69: * @param idna UIDNA instance jpayne@69: * @param name Input domain name jpayne@69: * @param length Domain name length, or -1 if NUL-terminated jpayne@69: * @param dest Destination string buffer jpayne@69: * @param capacity Destination buffer capacity jpayne@69: * @param pInfo Output container of IDNA processing details. jpayne@69: * @param pErrorCode Standard ICU error code. Its input value must jpayne@69: * pass the U_SUCCESS() test, or else the function returns jpayne@69: * immediately. Check for U_FAILURE() on output or use with jpayne@69: * function chaining. (See User Guide for details.) jpayne@69: * @return destination string length jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: uidna_nameToASCII(const UIDNA *idna, jpayne@69: const UChar *name, int32_t length, jpayne@69: UChar *dest, int32_t capacity, jpayne@69: UIDNAInfo *pInfo, UErrorCode *pErrorCode); jpayne@69: jpayne@69: /** jpayne@69: * Converts a whole domain name into its Unicode form for human-readable display. jpayne@69: * If any processing step fails, then pInfo->errors will be non-zero. jpayne@69: * The domain name might be modified according to the types of errors. jpayne@69: * jpayne@69: * The UErrorCode indicates an error only in exceptional cases, jpayne@69: * such as a U_MEMORY_ALLOCATION_ERROR. jpayne@69: * jpayne@69: * @param idna UIDNA instance jpayne@69: * @param name Input domain name jpayne@69: * @param length Domain name length, or -1 if NUL-terminated jpayne@69: * @param dest Destination string buffer jpayne@69: * @param capacity Destination buffer capacity jpayne@69: * @param pInfo Output container of IDNA processing details. jpayne@69: * @param pErrorCode Standard ICU error code. Its input value must jpayne@69: * pass the U_SUCCESS() test, or else the function returns jpayne@69: * immediately. Check for U_FAILURE() on output or use with jpayne@69: * function chaining. (See User Guide for details.) jpayne@69: * @return destination string length jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: uidna_nameToUnicode(const UIDNA *idna, jpayne@69: const UChar *name, int32_t length, jpayne@69: UChar *dest, int32_t capacity, jpayne@69: UIDNAInfo *pInfo, UErrorCode *pErrorCode); jpayne@69: jpayne@69: /* UTF-8 versions of the processing methods --------------------------------- */ jpayne@69: jpayne@69: /** jpayne@69: * Converts a single domain name label into its ASCII form for DNS lookup. jpayne@69: * UTF-8 version of uidna_labelToASCII(), same behavior. jpayne@69: * jpayne@69: * @param idna UIDNA instance jpayne@69: * @param label Input domain name label jpayne@69: * @param length Label length, or -1 if NUL-terminated jpayne@69: * @param dest Destination string buffer jpayne@69: * @param capacity Destination buffer capacity jpayne@69: * @param pInfo Output container of IDNA processing details. jpayne@69: * @param pErrorCode Standard ICU error code. Its input value must jpayne@69: * pass the U_SUCCESS() test, or else the function returns jpayne@69: * immediately. Check for U_FAILURE() on output or use with jpayne@69: * function chaining. (See User Guide for details.) jpayne@69: * @return destination string length jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: uidna_labelToASCII_UTF8(const UIDNA *idna, jpayne@69: const char *label, int32_t length, jpayne@69: char *dest, int32_t capacity, jpayne@69: UIDNAInfo *pInfo, UErrorCode *pErrorCode); jpayne@69: jpayne@69: /** jpayne@69: * Converts a single domain name label into its Unicode form for human-readable display. jpayne@69: * UTF-8 version of uidna_labelToUnicode(), same behavior. jpayne@69: * jpayne@69: * @param idna UIDNA instance jpayne@69: * @param label Input domain name label jpayne@69: * @param length Label length, or -1 if NUL-terminated jpayne@69: * @param dest Destination string buffer jpayne@69: * @param capacity Destination buffer capacity jpayne@69: * @param pInfo Output container of IDNA processing details. jpayne@69: * @param pErrorCode Standard ICU error code. Its input value must jpayne@69: * pass the U_SUCCESS() test, or else the function returns jpayne@69: * immediately. Check for U_FAILURE() on output or use with jpayne@69: * function chaining. (See User Guide for details.) jpayne@69: * @return destination string length jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: uidna_labelToUnicodeUTF8(const UIDNA *idna, jpayne@69: const char *label, int32_t length, jpayne@69: char *dest, int32_t capacity, jpayne@69: UIDNAInfo *pInfo, UErrorCode *pErrorCode); jpayne@69: jpayne@69: /** jpayne@69: * Converts a whole domain name into its ASCII form for DNS lookup. jpayne@69: * UTF-8 version of uidna_nameToASCII(), same behavior. jpayne@69: * jpayne@69: * @param idna UIDNA instance jpayne@69: * @param name Input domain name jpayne@69: * @param length Domain name length, or -1 if NUL-terminated jpayne@69: * @param dest Destination string buffer jpayne@69: * @param capacity Destination buffer capacity jpayne@69: * @param pInfo Output container of IDNA processing details. jpayne@69: * @param pErrorCode Standard ICU error code. Its input value must jpayne@69: * pass the U_SUCCESS() test, or else the function returns jpayne@69: * immediately. Check for U_FAILURE() on output or use with jpayne@69: * function chaining. (See User Guide for details.) jpayne@69: * @return destination string length jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: uidna_nameToASCII_UTF8(const UIDNA *idna, jpayne@69: const char *name, int32_t length, jpayne@69: char *dest, int32_t capacity, jpayne@69: UIDNAInfo *pInfo, UErrorCode *pErrorCode); jpayne@69: jpayne@69: /** jpayne@69: * Converts a whole domain name into its Unicode form for human-readable display. jpayne@69: * UTF-8 version of uidna_nameToUnicode(), same behavior. jpayne@69: * jpayne@69: * @param idna UIDNA instance jpayne@69: * @param name Input domain name jpayne@69: * @param length Domain name length, or -1 if NUL-terminated jpayne@69: * @param dest Destination string buffer jpayne@69: * @param capacity Destination buffer capacity jpayne@69: * @param pInfo Output container of IDNA processing details. jpayne@69: * @param pErrorCode Standard ICU error code. Its input value must jpayne@69: * pass the U_SUCCESS() test, or else the function returns jpayne@69: * immediately. Check for U_FAILURE() on output or use with jpayne@69: * function chaining. (See User Guide for details.) jpayne@69: * @return destination string length jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: U_STABLE int32_t U_EXPORT2 jpayne@69: uidna_nameToUnicodeUTF8(const UIDNA *idna, jpayne@69: const char *name, int32_t length, jpayne@69: char *dest, int32_t capacity, jpayne@69: UIDNAInfo *pInfo, UErrorCode *pErrorCode); jpayne@69: jpayne@69: /* jpayne@69: * IDNA error bit set values. jpayne@69: * When a domain name or label fails a processing step or does not meet the jpayne@69: * validity criteria, then one or more of these error bits are set. jpayne@69: */ jpayne@69: enum { jpayne@69: /** jpayne@69: * A non-final domain name label (or the whole domain name) is empty. jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_ERROR_EMPTY_LABEL=1, jpayne@69: /** jpayne@69: * A domain name label is longer than 63 bytes. jpayne@69: * (See STD13/RFC1034 3.1. Name space specifications and terminology.) jpayne@69: * This is only checked in ToASCII operations, and only if the output label is all-ASCII. jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_ERROR_LABEL_TOO_LONG=2, jpayne@69: /** jpayne@69: * A domain name is longer than 255 bytes in its storage form. jpayne@69: * (See STD13/RFC1034 3.1. Name space specifications and terminology.) jpayne@69: * This is only checked in ToASCII operations, and only if the output domain name is all-ASCII. jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_ERROR_DOMAIN_NAME_TOO_LONG=4, jpayne@69: /** jpayne@69: * A label starts with a hyphen-minus ('-'). jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_ERROR_LEADING_HYPHEN=8, jpayne@69: /** jpayne@69: * A label ends with a hyphen-minus ('-'). jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_ERROR_TRAILING_HYPHEN=0x10, jpayne@69: /** jpayne@69: * A label contains hyphen-minus ('-') in the third and fourth positions. jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_ERROR_HYPHEN_3_4=0x20, jpayne@69: /** jpayne@69: * A label starts with a combining mark. jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_ERROR_LEADING_COMBINING_MARK=0x40, jpayne@69: /** jpayne@69: * A label or domain name contains disallowed characters. jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_ERROR_DISALLOWED=0x80, jpayne@69: /** jpayne@69: * A label starts with "xn--" but does not contain valid Punycode. jpayne@69: * That is, an xn-- label failed Punycode decoding. jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_ERROR_PUNYCODE=0x100, jpayne@69: /** jpayne@69: * A label contains a dot=full stop. jpayne@69: * This can occur in an input string for a single-label function. jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_ERROR_LABEL_HAS_DOT=0x200, jpayne@69: /** jpayne@69: * An ACE label does not contain a valid label string. jpayne@69: * The label was successfully ACE (Punycode) decoded but the resulting jpayne@69: * string had severe validation errors. For example, jpayne@69: * it might contain characters that are not allowed in ACE labels, jpayne@69: * or it might not be normalized. jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_ERROR_INVALID_ACE_LABEL=0x400, jpayne@69: /** jpayne@69: * A label does not meet the IDNA BiDi requirements (for right-to-left characters). jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_ERROR_BIDI=0x800, jpayne@69: /** jpayne@69: * A label does not meet the IDNA CONTEXTJ requirements. jpayne@69: * @stable ICU 4.6 jpayne@69: */ jpayne@69: UIDNA_ERROR_CONTEXTJ=0x1000, jpayne@69: /** jpayne@69: * A label does not meet the IDNA CONTEXTO requirements for punctuation characters. jpayne@69: * Some punctuation characters "Would otherwise have been DISALLOWED" jpayne@69: * but are allowed in certain contexts. (RFC 5892) jpayne@69: * @stable ICU 49 jpayne@69: */ jpayne@69: UIDNA_ERROR_CONTEXTO_PUNCTUATION=0x2000, jpayne@69: /** jpayne@69: * A label does not meet the IDNA CONTEXTO requirements for digits. jpayne@69: * Arabic-Indic Digits (U+066x) must not be mixed with Extended Arabic-Indic Digits (U+06Fx). jpayne@69: * @stable ICU 49 jpayne@69: */ jpayne@69: UIDNA_ERROR_CONTEXTO_DIGITS=0x4000 jpayne@69: }; jpayne@69: jpayne@69: #ifndef U_HIDE_DEPRECATED_API jpayne@69: jpayne@69: /* IDNA2003 API ------------------------------------------------------------- */ jpayne@69: jpayne@69: /** jpayne@69: * IDNA2003: This function implements the ToASCII operation as defined in the IDNA RFC. jpayne@69: * This operation is done on single labels before sending it to something that expects jpayne@69: * ASCII names. A label is an individual part of a domain name. Labels are usually jpayne@69: * separated by dots; e.g. "www.example.com" is composed of 3 labels "www","example", and "com". jpayne@69: * jpayne@69: * IDNA2003 API Overview: jpayne@69: * jpayne@69: * The uidna_ API implements the IDNA protocol as defined in the IDNA RFC jpayne@69: * (http://www.ietf.org/rfc/rfc3490.txt). jpayne@69: * The RFC defines 2 operations: ToASCII and ToUnicode. Domain name labels jpayne@69: * containing non-ASCII code points are processed by the jpayne@69: * ToASCII operation before passing it to resolver libraries. Domain names jpayne@69: * that are obtained from resolver libraries are processed by the jpayne@69: * ToUnicode operation before displaying the domain name to the user. jpayne@69: * IDNA requires that implementations process input strings with Nameprep jpayne@69: * (http://www.ietf.org/rfc/rfc3491.txt), jpayne@69: * which is a profile of Stringprep (http://www.ietf.org/rfc/rfc3454.txt), jpayne@69: * and then with Punycode (http://www.ietf.org/rfc/rfc3492.txt). jpayne@69: * Implementations of IDNA MUST fully implement Nameprep and Punycode; jpayne@69: * neither Nameprep nor Punycode are optional. jpayne@69: * The input and output of ToASCII and ToUnicode operations are Unicode jpayne@69: * and are designed to be chainable, i.e., applying ToASCII or ToUnicode operations jpayne@69: * multiple times to an input string will yield the same result as applying the operation jpayne@69: * once. jpayne@69: * ToUnicode(ToUnicode(ToUnicode...(ToUnicode(string)))) == ToUnicode(string) jpayne@69: * ToASCII(ToASCII(ToASCII...(ToASCII(string))) == ToASCII(string). jpayne@69: * jpayne@69: * @param src Input UChar array containing label in Unicode. jpayne@69: * @param srcLength Number of UChars in src, or -1 if NUL-terminated. jpayne@69: * @param dest Output UChar array with ASCII (ACE encoded) label. jpayne@69: * @param destCapacity Size of dest. jpayne@69: * @param options A bit set of options: jpayne@69: * jpayne@69: * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points jpayne@69: * and do not use STD3 ASCII rules jpayne@69: * If unassigned code points are found the operation fails with jpayne@69: * U_UNASSIGNED_ERROR error code. jpayne@69: * jpayne@69: * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations jpayne@69: * If this option is set, the unassigned code points are in the input jpayne@69: * are treated as normal Unicode code points. jpayne@69: * jpayne@69: * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions jpayne@69: * If this option is set and the input does not satisfy STD3 rules, jpayne@69: * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR jpayne@69: * jpayne@69: * @param parseError Pointer to UParseError struct to receive information on position jpayne@69: * of error if an error is encountered. Can be NULL. jpayne@69: * @param status ICU in/out error code parameter. jpayne@69: * U_INVALID_CHAR_FOUND if src contains jpayne@69: * unmatched single surrogates. jpayne@69: * U_INDEX_OUTOFBOUNDS_ERROR if src contains jpayne@69: * too many code points. jpayne@69: * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough jpayne@69: * @return The length of the result string, if successful - or in case of a buffer overflow, jpayne@69: * in which case it will be greater than destCapacity. jpayne@69: * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. jpayne@69: */ jpayne@69: U_DEPRECATED int32_t U_EXPORT2 jpayne@69: uidna_toASCII(const UChar* src, int32_t srcLength, jpayne@69: UChar* dest, int32_t destCapacity, jpayne@69: int32_t options, jpayne@69: UParseError* parseError, jpayne@69: UErrorCode* status); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * IDNA2003: This function implements the ToUnicode operation as defined in the IDNA RFC. jpayne@69: * This operation is done on single labels before sending it to something that expects jpayne@69: * Unicode names. A label is an individual part of a domain name. Labels are usually jpayne@69: * separated by dots; for e.g. "www.example.com" is composed of 3 labels "www","example", and "com". jpayne@69: * jpayne@69: * @param src Input UChar array containing ASCII (ACE encoded) label. jpayne@69: * @param srcLength Number of UChars in src, or -1 if NUL-terminated. jpayne@69: * @param dest Output Converted UChar array containing Unicode equivalent of label. jpayne@69: * @param destCapacity Size of dest. jpayne@69: * @param options A bit set of options: jpayne@69: * jpayne@69: * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points jpayne@69: * and do not use STD3 ASCII rules jpayne@69: * If unassigned code points are found the operation fails with jpayne@69: * U_UNASSIGNED_ERROR error code. jpayne@69: * jpayne@69: * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations jpayne@69: * If this option is set, the unassigned code points are in the input jpayne@69: * are treated as normal Unicode code points. Note: This option is jpayne@69: * required on toUnicode operation because the RFC mandates jpayne@69: * verification of decoded ACE input by applying toASCII and comparing jpayne@69: * its output with source jpayne@69: * jpayne@69: * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions jpayne@69: * If this option is set and the input does not satisfy STD3 rules, jpayne@69: * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR jpayne@69: * jpayne@69: * @param parseError Pointer to UParseError struct to receive information on position jpayne@69: * of error if an error is encountered. Can be NULL. jpayne@69: * @param status ICU in/out error code parameter. jpayne@69: * U_INVALID_CHAR_FOUND if src contains jpayne@69: * unmatched single surrogates. jpayne@69: * U_INDEX_OUTOFBOUNDS_ERROR if src contains jpayne@69: * too many code points. jpayne@69: * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough jpayne@69: * @return The length of the result string, if successful - or in case of a buffer overflow, jpayne@69: * in which case it will be greater than destCapacity. jpayne@69: * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. jpayne@69: */ jpayne@69: U_DEPRECATED int32_t U_EXPORT2 jpayne@69: uidna_toUnicode(const UChar* src, int32_t srcLength, jpayne@69: UChar* dest, int32_t destCapacity, jpayne@69: int32_t options, jpayne@69: UParseError* parseError, jpayne@69: UErrorCode* status); jpayne@69: jpayne@69: jpayne@69: /** jpayne@69: * IDNA2003: Convenience function that implements the IDNToASCII operation as defined in the IDNA RFC. jpayne@69: * This operation is done on complete domain names, e.g: "www.example.com". jpayne@69: * It is important to note that this operation can fail. If it fails, then the input jpayne@69: * domain name cannot be used as an Internationalized Domain Name and the application jpayne@69: * should have methods defined to deal with the failure. jpayne@69: * jpayne@69: * Note: IDNA RFC specifies that a conformant application should divide a domain name jpayne@69: * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, jpayne@69: * and then convert. This function does not offer that level of granularity. The options once jpayne@69: * set will apply to all labels in the domain name jpayne@69: * jpayne@69: * @param src Input UChar array containing IDN in Unicode. jpayne@69: * @param srcLength Number of UChars in src, or -1 if NUL-terminated. jpayne@69: * @param dest Output UChar array with ASCII (ACE encoded) IDN. jpayne@69: * @param destCapacity Size of dest. jpayne@69: * @param options A bit set of options: jpayne@69: * jpayne@69: * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points jpayne@69: * and do not use STD3 ASCII rules jpayne@69: * If unassigned code points are found the operation fails with jpayne@69: * U_UNASSIGNED_CODE_POINT_FOUND error code. jpayne@69: * jpayne@69: * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations jpayne@69: * If this option is set, the unassigned code points are in the input jpayne@69: * are treated as normal Unicode code points. jpayne@69: * jpayne@69: * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions jpayne@69: * If this option is set and the input does not satisfy STD3 rules, jpayne@69: * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR jpayne@69: * jpayne@69: * @param parseError Pointer to UParseError struct to receive information on position jpayne@69: * of error if an error is encountered. Can be NULL. jpayne@69: * @param status ICU in/out error code parameter. jpayne@69: * U_INVALID_CHAR_FOUND if src contains jpayne@69: * unmatched single surrogates. jpayne@69: * U_INDEX_OUTOFBOUNDS_ERROR if src contains jpayne@69: * too many code points. jpayne@69: * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough jpayne@69: * @return The length of the result string, if successful - or in case of a buffer overflow, jpayne@69: * in which case it will be greater than destCapacity. jpayne@69: * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. jpayne@69: */ jpayne@69: U_DEPRECATED int32_t U_EXPORT2 jpayne@69: uidna_IDNToASCII( const UChar* src, int32_t srcLength, jpayne@69: UChar* dest, int32_t destCapacity, jpayne@69: int32_t options, jpayne@69: UParseError* parseError, jpayne@69: UErrorCode* status); jpayne@69: jpayne@69: /** jpayne@69: * IDNA2003: Convenience function that implements the IDNToUnicode operation as defined in the IDNA RFC. jpayne@69: * This operation is done on complete domain names, e.g: "www.example.com". jpayne@69: * jpayne@69: * Note: IDNA RFC specifies that a conformant application should divide a domain name jpayne@69: * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, jpayne@69: * and then convert. This function does not offer that level of granularity. The options once jpayne@69: * set will apply to all labels in the domain name jpayne@69: * jpayne@69: * @param src Input UChar array containing IDN in ASCII (ACE encoded) form. jpayne@69: * @param srcLength Number of UChars in src, or -1 if NUL-terminated. jpayne@69: * @param dest Output UChar array containing Unicode equivalent of source IDN. jpayne@69: * @param destCapacity Size of dest. jpayne@69: * @param options A bit set of options: jpayne@69: * jpayne@69: * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points jpayne@69: * and do not use STD3 ASCII rules jpayne@69: * If unassigned code points are found the operation fails with jpayne@69: * U_UNASSIGNED_CODE_POINT_FOUND error code. jpayne@69: * jpayne@69: * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations jpayne@69: * If this option is set, the unassigned code points are in the input jpayne@69: * are treated as normal Unicode code points. jpayne@69: * jpayne@69: * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions jpayne@69: * If this option is set and the input does not satisfy STD3 rules, jpayne@69: * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR jpayne@69: * jpayne@69: * @param parseError Pointer to UParseError struct to receive information on position jpayne@69: * of error if an error is encountered. Can be NULL. jpayne@69: * @param status ICU in/out error code parameter. jpayne@69: * U_INVALID_CHAR_FOUND if src contains jpayne@69: * unmatched single surrogates. jpayne@69: * U_INDEX_OUTOFBOUNDS_ERROR if src contains jpayne@69: * too many code points. jpayne@69: * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough jpayne@69: * @return The length of the result string, if successful - or in case of a buffer overflow, jpayne@69: * in which case it will be greater than destCapacity. jpayne@69: * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. jpayne@69: */ jpayne@69: U_DEPRECATED int32_t U_EXPORT2 jpayne@69: uidna_IDNToUnicode( const UChar* src, int32_t srcLength, jpayne@69: UChar* dest, int32_t destCapacity, jpayne@69: int32_t options, jpayne@69: UParseError* parseError, jpayne@69: UErrorCode* status); jpayne@69: jpayne@69: /** jpayne@69: * IDNA2003: Compare two IDN strings for equivalence. jpayne@69: * This function splits the domain names into labels and compares them. jpayne@69: * According to IDN RFC, whenever two labels are compared, they are jpayne@69: * considered equal if and only if their ASCII forms (obtained by jpayne@69: * applying toASCII) match using an case-insensitive ASCII comparison. jpayne@69: * Two domain names are considered a match if and only if all labels jpayne@69: * match regardless of whether label separators match. jpayne@69: * jpayne@69: * @param s1 First source string. jpayne@69: * @param length1 Length of first source string, or -1 if NUL-terminated. jpayne@69: * jpayne@69: * @param s2 Second source string. jpayne@69: * @param length2 Length of second source string, or -1 if NUL-terminated. jpayne@69: * @param options A bit set of options: jpayne@69: * jpayne@69: * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points jpayne@69: * and do not use STD3 ASCII rules jpayne@69: * If unassigned code points are found the operation fails with jpayne@69: * U_UNASSIGNED_CODE_POINT_FOUND error code. jpayne@69: * jpayne@69: * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations jpayne@69: * If this option is set, the unassigned code points are in the input jpayne@69: * are treated as normal Unicode code points. jpayne@69: * jpayne@69: * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions jpayne@69: * If this option is set and the input does not satisfy STD3 rules, jpayne@69: * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR jpayne@69: * jpayne@69: * @param status ICU error code in/out parameter. jpayne@69: * Must fulfill U_SUCCESS before the function call. jpayne@69: * @return <0 or 0 or >0 as usual for string comparisons jpayne@69: * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. jpayne@69: */ jpayne@69: U_DEPRECATED int32_t U_EXPORT2 jpayne@69: uidna_compare( const UChar *s1, int32_t length1, jpayne@69: const UChar *s2, int32_t length2, jpayne@69: int32_t options, jpayne@69: UErrorCode* status); jpayne@69: jpayne@69: #endif /* U_HIDE_DEPRECATED_API */ jpayne@69: jpayne@69: #endif /* #if !UCONFIG_NO_IDNA */ jpayne@69: jpayne@69: #endif