1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others. 2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html 3*0e209d39SAndroid Build Coastguard Worker /* 4*0e209d39SAndroid Build Coastguard Worker ******************************************************************************* 5*0e209d39SAndroid Build Coastguard Worker * 6*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 2003-2014, International Business Machines 7*0e209d39SAndroid Build Coastguard Worker * Corporation and others. All Rights Reserved. 8*0e209d39SAndroid Build Coastguard Worker * 9*0e209d39SAndroid Build Coastguard Worker ******************************************************************************* 10*0e209d39SAndroid Build Coastguard Worker * file name: uidna.h 11*0e209d39SAndroid Build Coastguard Worker * encoding: UTF-8 12*0e209d39SAndroid Build Coastguard Worker * tab size: 8 (not used) 13*0e209d39SAndroid Build Coastguard Worker * indentation:4 14*0e209d39SAndroid Build Coastguard Worker * 15*0e209d39SAndroid Build Coastguard Worker * created on: 2003feb1 16*0e209d39SAndroid Build Coastguard Worker * created by: Ram Viswanadha 17*0e209d39SAndroid Build Coastguard Worker */ 18*0e209d39SAndroid Build Coastguard Worker 19*0e209d39SAndroid Build Coastguard Worker #ifndef __UIDNA_H__ 20*0e209d39SAndroid Build Coastguard Worker #define __UIDNA_H__ 21*0e209d39SAndroid Build Coastguard Worker 22*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 23*0e209d39SAndroid Build Coastguard Worker 24*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_IDNA 25*0e209d39SAndroid Build Coastguard Worker 26*0e209d39SAndroid Build Coastguard Worker #include <stdbool.h> 27*0e209d39SAndroid Build Coastguard Worker #include "unicode/parseerr.h" 28*0e209d39SAndroid Build Coastguard Worker 29*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 30*0e209d39SAndroid Build Coastguard Worker #include "unicode/localpointer.h" 31*0e209d39SAndroid Build Coastguard Worker #endif // U_SHOW_CPLUSPLUS_API 32*0e209d39SAndroid Build Coastguard Worker 33*0e209d39SAndroid Build Coastguard Worker /** 34*0e209d39SAndroid Build Coastguard Worker * \file 35*0e209d39SAndroid Build Coastguard Worker * \brief C API: Internationalizing Domain Names in Applications (IDNA) 36*0e209d39SAndroid Build Coastguard Worker * 37*0e209d39SAndroid Build Coastguard Worker * IDNA2008 is implemented according to UTS #46, see the IDNA C++ class in idna.h. 38*0e209d39SAndroid Build Coastguard Worker * 39*0e209d39SAndroid Build Coastguard Worker * The C API functions which do take a UIDNA * service object pointer 40*0e209d39SAndroid Build Coastguard Worker * implement UTS #46 and IDNA2008. 41*0e209d39SAndroid Build Coastguard Worker * 42*0e209d39SAndroid Build Coastguard Worker * IDNA2003 is obsolete. 43*0e209d39SAndroid Build Coastguard Worker * The C API functions which do not take a service object pointer 44*0e209d39SAndroid Build Coastguard Worker * implement IDNA2003. They are all deprecated. 45*0e209d39SAndroid Build Coastguard Worker */ 46*0e209d39SAndroid Build Coastguard Worker 47*0e209d39SAndroid Build Coastguard Worker /* 48*0e209d39SAndroid Build Coastguard Worker * IDNA option bit set values. 49*0e209d39SAndroid Build Coastguard Worker */ 50*0e209d39SAndroid Build Coastguard Worker enum { 51*0e209d39SAndroid Build Coastguard Worker /** 52*0e209d39SAndroid Build Coastguard Worker * Default options value: None of the other options are set. 53*0e209d39SAndroid Build Coastguard Worker * For use in static worker and factory methods. 54*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.6 55*0e209d39SAndroid Build Coastguard Worker */ 56*0e209d39SAndroid Build Coastguard Worker UIDNA_DEFAULT=0, 57*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 58*0e209d39SAndroid Build Coastguard Worker /** 59*0e209d39SAndroid Build Coastguard Worker * Option to allow unassigned code points in domain names and labels. 60*0e209d39SAndroid Build Coastguard Worker * For use in static worker and factory methods. 61*0e209d39SAndroid Build Coastguard Worker * <p>This option is ignored by the UTS46 implementation. 62*0e209d39SAndroid Build Coastguard Worker * (UTS #46 disallows unassigned code points.) 63*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. 64*0e209d39SAndroid Build Coastguard Worker */ 65*0e209d39SAndroid Build Coastguard Worker UIDNA_ALLOW_UNASSIGNED=1, 66*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 67*0e209d39SAndroid Build Coastguard Worker /** 68*0e209d39SAndroid Build Coastguard Worker * Option to check whether the input conforms to the STD3 ASCII rules, 69*0e209d39SAndroid Build Coastguard Worker * for example the restriction of labels to LDH characters 70*0e209d39SAndroid Build Coastguard Worker * (ASCII Letters, Digits and Hyphen-Minus). 71*0e209d39SAndroid Build Coastguard Worker * For use in static worker and factory methods. 72*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.6 73*0e209d39SAndroid Build Coastguard Worker */ 74*0e209d39SAndroid Build Coastguard Worker UIDNA_USE_STD3_RULES=2, 75*0e209d39SAndroid Build Coastguard Worker /** 76*0e209d39SAndroid Build Coastguard Worker * IDNA option to check for whether the input conforms to the BiDi rules. 77*0e209d39SAndroid Build Coastguard Worker * For use in static worker and factory methods. 78*0e209d39SAndroid Build Coastguard Worker * <p>This option is ignored by the IDNA2003 implementation. 79*0e209d39SAndroid Build Coastguard Worker * (IDNA2003 always performs a BiDi check.) 80*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 81*0e209d39SAndroid Build Coastguard Worker */ 82*0e209d39SAndroid Build Coastguard Worker UIDNA_CHECK_BIDI=4, 83*0e209d39SAndroid Build Coastguard Worker /** 84*0e209d39SAndroid Build Coastguard Worker * IDNA option to check for whether the input conforms to the CONTEXTJ rules. 85*0e209d39SAndroid Build Coastguard Worker * For use in static worker and factory methods. 86*0e209d39SAndroid Build Coastguard Worker * <p>This option is ignored by the IDNA2003 implementation. 87*0e209d39SAndroid Build Coastguard Worker * (The CONTEXTJ check is new in IDNA2008.) 88*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 89*0e209d39SAndroid Build Coastguard Worker */ 90*0e209d39SAndroid Build Coastguard Worker UIDNA_CHECK_CONTEXTJ=8, 91*0e209d39SAndroid Build Coastguard Worker /** 92*0e209d39SAndroid Build Coastguard Worker * IDNA option for nontransitional processing in ToASCII(). 93*0e209d39SAndroid Build Coastguard Worker * For use in static worker and factory methods. 94*0e209d39SAndroid Build Coastguard Worker * <p>By default, ToASCII() uses transitional processing. 95*0e209d39SAndroid Build Coastguard Worker * <p>This option is ignored by the IDNA2003 implementation. 96*0e209d39SAndroid Build Coastguard Worker * (This is only relevant for compatibility of newer IDNA implementations with IDNA2003.) 97*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 98*0e209d39SAndroid Build Coastguard Worker */ 99*0e209d39SAndroid Build Coastguard Worker UIDNA_NONTRANSITIONAL_TO_ASCII=0x10, 100*0e209d39SAndroid Build Coastguard Worker /** 101*0e209d39SAndroid Build Coastguard Worker * IDNA option for nontransitional processing in ToUnicode(). 102*0e209d39SAndroid Build Coastguard Worker * For use in static worker and factory methods. 103*0e209d39SAndroid Build Coastguard Worker * <p>By default, ToUnicode() uses transitional processing. 104*0e209d39SAndroid Build Coastguard Worker * <p>This option is ignored by the IDNA2003 implementation. 105*0e209d39SAndroid Build Coastguard Worker * (This is only relevant for compatibility of newer IDNA implementations with IDNA2003.) 106*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 107*0e209d39SAndroid Build Coastguard Worker */ 108*0e209d39SAndroid Build Coastguard Worker UIDNA_NONTRANSITIONAL_TO_UNICODE=0x20, 109*0e209d39SAndroid Build Coastguard Worker /** 110*0e209d39SAndroid Build Coastguard Worker * IDNA option to check for whether the input conforms to the CONTEXTO rules. 111*0e209d39SAndroid Build Coastguard Worker * For use in static worker and factory methods. 112*0e209d39SAndroid Build Coastguard Worker * <p>This option is ignored by the IDNA2003 implementation. 113*0e209d39SAndroid Build Coastguard Worker * (The CONTEXTO check is new in IDNA2008.) 114*0e209d39SAndroid Build Coastguard Worker * <p>This is for use by registries for IDNA2008 conformance. 115*0e209d39SAndroid Build Coastguard Worker * UTS #46 does not require the CONTEXTO check. 116*0e209d39SAndroid Build Coastguard Worker * @stable ICU 49 117*0e209d39SAndroid Build Coastguard Worker */ 118*0e209d39SAndroid Build Coastguard Worker UIDNA_CHECK_CONTEXTO=0x40 119*0e209d39SAndroid Build Coastguard Worker }; 120*0e209d39SAndroid Build Coastguard Worker 121*0e209d39SAndroid Build Coastguard Worker /** 122*0e209d39SAndroid Build Coastguard Worker * Opaque C service object type for the new IDNA API. 123*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 124*0e209d39SAndroid Build Coastguard Worker */ 125*0e209d39SAndroid Build Coastguard Worker struct UIDNA; 126*0e209d39SAndroid Build Coastguard Worker typedef struct UIDNA UIDNA; /**< C typedef for struct UIDNA. @stable ICU 4.6 */ 127*0e209d39SAndroid Build Coastguard Worker 128*0e209d39SAndroid Build Coastguard Worker /** 129*0e209d39SAndroid Build Coastguard Worker * Returns a UIDNA instance which implements UTS #46. 130*0e209d39SAndroid Build Coastguard Worker * Returns an unmodifiable instance, owned by the caller. 131*0e209d39SAndroid Build Coastguard Worker * Cache it for multiple operations, and uidna_close() it when done. 132*0e209d39SAndroid Build Coastguard Worker * The instance is thread-safe, that is, it can be used concurrently. 133*0e209d39SAndroid Build Coastguard Worker * 134*0e209d39SAndroid Build Coastguard Worker * For details about the UTS #46 implementation see the IDNA C++ class in idna.h. 135*0e209d39SAndroid Build Coastguard Worker * 136*0e209d39SAndroid Build Coastguard Worker * @param options Bit set to modify the processing and error checking. 137*0e209d39SAndroid Build Coastguard Worker * See option bit set values in uidna.h. 138*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Standard ICU error code. Its input value must 139*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns 140*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with 141*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.) 142*0e209d39SAndroid Build Coastguard Worker * @return the UTS #46 UIDNA instance, if successful 143*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 144*0e209d39SAndroid Build Coastguard Worker */ 145*0e209d39SAndroid Build Coastguard Worker U_CAPI UIDNA * U_EXPORT2 146*0e209d39SAndroid Build Coastguard Worker uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode); 147*0e209d39SAndroid Build Coastguard Worker 148*0e209d39SAndroid Build Coastguard Worker /** 149*0e209d39SAndroid Build Coastguard Worker * Closes a UIDNA instance. 150*0e209d39SAndroid Build Coastguard Worker * @param idna UIDNA instance to be closed 151*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 152*0e209d39SAndroid Build Coastguard Worker */ 153*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 154*0e209d39SAndroid Build Coastguard Worker uidna_close(UIDNA *idna); 155*0e209d39SAndroid Build Coastguard Worker 156*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 157*0e209d39SAndroid Build Coastguard Worker 158*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 159*0e209d39SAndroid Build Coastguard Worker 160*0e209d39SAndroid Build Coastguard Worker /** 161*0e209d39SAndroid Build Coastguard Worker * \class LocalUIDNAPointer 162*0e209d39SAndroid Build Coastguard Worker * "Smart pointer" class, closes a UIDNA via uidna_close(). 163*0e209d39SAndroid Build Coastguard Worker * For most methods see the LocalPointerBase base class. 164*0e209d39SAndroid Build Coastguard Worker * 165*0e209d39SAndroid Build Coastguard Worker * @see LocalPointerBase 166*0e209d39SAndroid Build Coastguard Worker * @see LocalPointer 167*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 168*0e209d39SAndroid Build Coastguard Worker */ 169*0e209d39SAndroid Build Coastguard Worker U_DEFINE_LOCAL_OPEN_POINTER(LocalUIDNAPointer, UIDNA, uidna_close); 170*0e209d39SAndroid Build Coastguard Worker 171*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 172*0e209d39SAndroid Build Coastguard Worker 173*0e209d39SAndroid Build Coastguard Worker #endif 174*0e209d39SAndroid Build Coastguard Worker 175*0e209d39SAndroid Build Coastguard Worker /** 176*0e209d39SAndroid Build Coastguard Worker * Output container for IDNA processing errors. 177*0e209d39SAndroid Build Coastguard Worker * Initialize with UIDNA_INFO_INITIALIZER: 178*0e209d39SAndroid Build Coastguard Worker * \code 179*0e209d39SAndroid Build Coastguard Worker * UIDNAInfo info = UIDNA_INFO_INITIALIZER; 180*0e209d39SAndroid Build Coastguard Worker * int32_t length = uidna_nameToASCII(..., &info, &errorCode); 181*0e209d39SAndroid Build Coastguard Worker * if(U_SUCCESS(errorCode) && info.errors!=0) { ... } 182*0e209d39SAndroid Build Coastguard Worker * \endcode 183*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 184*0e209d39SAndroid Build Coastguard Worker */ 185*0e209d39SAndroid Build Coastguard Worker typedef struct UIDNAInfo { 186*0e209d39SAndroid Build Coastguard Worker /** sizeof(UIDNAInfo) @stable ICU 4.6 */ 187*0e209d39SAndroid Build Coastguard Worker int16_t size; 188*0e209d39SAndroid Build Coastguard Worker /** 189*0e209d39SAndroid Build Coastguard Worker * Set to true if transitional and nontransitional processing produce different results. 190*0e209d39SAndroid Build Coastguard Worker * For details see C++ IDNAInfo::isTransitionalDifferent(). 191*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 192*0e209d39SAndroid Build Coastguard Worker */ 193*0e209d39SAndroid Build Coastguard Worker UBool isTransitionalDifferent; 194*0e209d39SAndroid Build Coastguard Worker UBool reservedB3; /**< Reserved field, do not use. @internal */ 195*0e209d39SAndroid Build Coastguard Worker /** 196*0e209d39SAndroid Build Coastguard Worker * Bit set indicating IDNA processing errors. 0 if no errors. 197*0e209d39SAndroid Build Coastguard Worker * See UIDNA_ERROR_... constants. 198*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 199*0e209d39SAndroid Build Coastguard Worker */ 200*0e209d39SAndroid Build Coastguard Worker uint32_t errors; 201*0e209d39SAndroid Build Coastguard Worker int32_t reservedI2; /**< Reserved field, do not use. @internal */ 202*0e209d39SAndroid Build Coastguard Worker int32_t reservedI3; /**< Reserved field, do not use. @internal */ 203*0e209d39SAndroid Build Coastguard Worker } UIDNAInfo; 204*0e209d39SAndroid Build Coastguard Worker 205*0e209d39SAndroid Build Coastguard Worker /** 206*0e209d39SAndroid Build Coastguard Worker * Static initializer for a UIDNAInfo struct. 207*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 208*0e209d39SAndroid Build Coastguard Worker */ 209*0e209d39SAndroid Build Coastguard Worker #define UIDNA_INFO_INITIALIZER { \ 210*0e209d39SAndroid Build Coastguard Worker (int16_t)sizeof(UIDNAInfo), \ 211*0e209d39SAndroid Build Coastguard Worker false, false, \ 212*0e209d39SAndroid Build Coastguard Worker 0, 0, 0 } 213*0e209d39SAndroid Build Coastguard Worker 214*0e209d39SAndroid Build Coastguard Worker /** 215*0e209d39SAndroid Build Coastguard Worker * Converts a single domain name label into its ASCII form for DNS lookup. 216*0e209d39SAndroid Build Coastguard Worker * If any processing step fails, then pInfo->errors will be non-zero and 217*0e209d39SAndroid Build Coastguard Worker * the result might not be an ASCII string. 218*0e209d39SAndroid Build Coastguard Worker * The label might be modified according to the types of errors. 219*0e209d39SAndroid Build Coastguard Worker * Labels with severe errors will be left in (or turned into) their Unicode form. 220*0e209d39SAndroid Build Coastguard Worker * 221*0e209d39SAndroid Build Coastguard Worker * The UErrorCode indicates an error only in exceptional cases, 222*0e209d39SAndroid Build Coastguard Worker * such as a U_MEMORY_ALLOCATION_ERROR. 223*0e209d39SAndroid Build Coastguard Worker * 224*0e209d39SAndroid Build Coastguard Worker * @param idna UIDNA instance 225*0e209d39SAndroid Build Coastguard Worker * @param label Input domain name label 226*0e209d39SAndroid Build Coastguard Worker * @param length Label length, or -1 if NUL-terminated 227*0e209d39SAndroid Build Coastguard Worker * @param dest Destination string buffer 228*0e209d39SAndroid Build Coastguard Worker * @param capacity Destination buffer capacity 229*0e209d39SAndroid Build Coastguard Worker * @param pInfo Output container of IDNA processing details. 230*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Standard ICU error code. Its input value must 231*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns 232*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with 233*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.) 234*0e209d39SAndroid Build Coastguard Worker * @return destination string length 235*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 236*0e209d39SAndroid Build Coastguard Worker */ 237*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 238*0e209d39SAndroid Build Coastguard Worker uidna_labelToASCII(const UIDNA *idna, 239*0e209d39SAndroid Build Coastguard Worker const UChar *label, int32_t length, 240*0e209d39SAndroid Build Coastguard Worker UChar *dest, int32_t capacity, 241*0e209d39SAndroid Build Coastguard Worker UIDNAInfo *pInfo, UErrorCode *pErrorCode); 242*0e209d39SAndroid Build Coastguard Worker 243*0e209d39SAndroid Build Coastguard Worker /** 244*0e209d39SAndroid Build Coastguard Worker * Converts a single domain name label into its Unicode form for human-readable display. 245*0e209d39SAndroid Build Coastguard Worker * If any processing step fails, then pInfo->errors will be non-zero. 246*0e209d39SAndroid Build Coastguard Worker * The label might be modified according to the types of errors. 247*0e209d39SAndroid Build Coastguard Worker * 248*0e209d39SAndroid Build Coastguard Worker * The UErrorCode indicates an error only in exceptional cases, 249*0e209d39SAndroid Build Coastguard Worker * such as a U_MEMORY_ALLOCATION_ERROR. 250*0e209d39SAndroid Build Coastguard Worker * 251*0e209d39SAndroid Build Coastguard Worker * @param idna UIDNA instance 252*0e209d39SAndroid Build Coastguard Worker * @param label Input domain name label 253*0e209d39SAndroid Build Coastguard Worker * @param length Label length, or -1 if NUL-terminated 254*0e209d39SAndroid Build Coastguard Worker * @param dest Destination string buffer 255*0e209d39SAndroid Build Coastguard Worker * @param capacity Destination buffer capacity 256*0e209d39SAndroid Build Coastguard Worker * @param pInfo Output container of IDNA processing details. 257*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Standard ICU error code. Its input value must 258*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns 259*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with 260*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.) 261*0e209d39SAndroid Build Coastguard Worker * @return destination string length 262*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 263*0e209d39SAndroid Build Coastguard Worker */ 264*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 265*0e209d39SAndroid Build Coastguard Worker uidna_labelToUnicode(const UIDNA *idna, 266*0e209d39SAndroid Build Coastguard Worker const UChar *label, int32_t length, 267*0e209d39SAndroid Build Coastguard Worker UChar *dest, int32_t capacity, 268*0e209d39SAndroid Build Coastguard Worker UIDNAInfo *pInfo, UErrorCode *pErrorCode); 269*0e209d39SAndroid Build Coastguard Worker 270*0e209d39SAndroid Build Coastguard Worker /** 271*0e209d39SAndroid Build Coastguard Worker * Converts a whole domain name into its ASCII form for DNS lookup. 272*0e209d39SAndroid Build Coastguard Worker * If any processing step fails, then pInfo->errors will be non-zero and 273*0e209d39SAndroid Build Coastguard Worker * the result might not be an ASCII string. 274*0e209d39SAndroid Build Coastguard Worker * The domain name might be modified according to the types of errors. 275*0e209d39SAndroid Build Coastguard Worker * Labels with severe errors will be left in (or turned into) their Unicode form. 276*0e209d39SAndroid Build Coastguard Worker * 277*0e209d39SAndroid Build Coastguard Worker * The UErrorCode indicates an error only in exceptional cases, 278*0e209d39SAndroid Build Coastguard Worker * such as a U_MEMORY_ALLOCATION_ERROR. 279*0e209d39SAndroid Build Coastguard Worker * 280*0e209d39SAndroid Build Coastguard Worker * @param idna UIDNA instance 281*0e209d39SAndroid Build Coastguard Worker * @param name Input domain name 282*0e209d39SAndroid Build Coastguard Worker * @param length Domain name length, or -1 if NUL-terminated 283*0e209d39SAndroid Build Coastguard Worker * @param dest Destination string buffer 284*0e209d39SAndroid Build Coastguard Worker * @param capacity Destination buffer capacity 285*0e209d39SAndroid Build Coastguard Worker * @param pInfo Output container of IDNA processing details. 286*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Standard ICU error code. Its input value must 287*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns 288*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with 289*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.) 290*0e209d39SAndroid Build Coastguard Worker * @return destination string length 291*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 292*0e209d39SAndroid Build Coastguard Worker */ 293*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 294*0e209d39SAndroid Build Coastguard Worker uidna_nameToASCII(const UIDNA *idna, 295*0e209d39SAndroid Build Coastguard Worker const UChar *name, int32_t length, 296*0e209d39SAndroid Build Coastguard Worker UChar *dest, int32_t capacity, 297*0e209d39SAndroid Build Coastguard Worker UIDNAInfo *pInfo, UErrorCode *pErrorCode); 298*0e209d39SAndroid Build Coastguard Worker 299*0e209d39SAndroid Build Coastguard Worker /** 300*0e209d39SAndroid Build Coastguard Worker * Converts a whole domain name into its Unicode form for human-readable display. 301*0e209d39SAndroid Build Coastguard Worker * If any processing step fails, then pInfo->errors will be non-zero. 302*0e209d39SAndroid Build Coastguard Worker * The domain name might be modified according to the types of errors. 303*0e209d39SAndroid Build Coastguard Worker * 304*0e209d39SAndroid Build Coastguard Worker * The UErrorCode indicates an error only in exceptional cases, 305*0e209d39SAndroid Build Coastguard Worker * such as a U_MEMORY_ALLOCATION_ERROR. 306*0e209d39SAndroid Build Coastguard Worker * 307*0e209d39SAndroid Build Coastguard Worker * @param idna UIDNA instance 308*0e209d39SAndroid Build Coastguard Worker * @param name Input domain name 309*0e209d39SAndroid Build Coastguard Worker * @param length Domain name length, or -1 if NUL-terminated 310*0e209d39SAndroid Build Coastguard Worker * @param dest Destination string buffer 311*0e209d39SAndroid Build Coastguard Worker * @param capacity Destination buffer capacity 312*0e209d39SAndroid Build Coastguard Worker * @param pInfo Output container of IDNA processing details. 313*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Standard ICU error code. Its input value must 314*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns 315*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with 316*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.) 317*0e209d39SAndroid Build Coastguard Worker * @return destination string length 318*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 319*0e209d39SAndroid Build Coastguard Worker */ 320*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 321*0e209d39SAndroid Build Coastguard Worker uidna_nameToUnicode(const UIDNA *idna, 322*0e209d39SAndroid Build Coastguard Worker const UChar *name, int32_t length, 323*0e209d39SAndroid Build Coastguard Worker UChar *dest, int32_t capacity, 324*0e209d39SAndroid Build Coastguard Worker UIDNAInfo *pInfo, UErrorCode *pErrorCode); 325*0e209d39SAndroid Build Coastguard Worker 326*0e209d39SAndroid Build Coastguard Worker /* UTF-8 versions of the processing methods --------------------------------- */ 327*0e209d39SAndroid Build Coastguard Worker 328*0e209d39SAndroid Build Coastguard Worker /** 329*0e209d39SAndroid Build Coastguard Worker * Converts a single domain name label into its ASCII form for DNS lookup. 330*0e209d39SAndroid Build Coastguard Worker * UTF-8 version of uidna_labelToASCII(), same behavior. 331*0e209d39SAndroid Build Coastguard Worker * 332*0e209d39SAndroid Build Coastguard Worker * @param idna UIDNA instance 333*0e209d39SAndroid Build Coastguard Worker * @param label Input domain name label 334*0e209d39SAndroid Build Coastguard Worker * @param length Label length, or -1 if NUL-terminated 335*0e209d39SAndroid Build Coastguard Worker * @param dest Destination string buffer 336*0e209d39SAndroid Build Coastguard Worker * @param capacity Destination buffer capacity 337*0e209d39SAndroid Build Coastguard Worker * @param pInfo Output container of IDNA processing details. 338*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Standard ICU error code. Its input value must 339*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns 340*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with 341*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.) 342*0e209d39SAndroid Build Coastguard Worker * @return destination string length 343*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 344*0e209d39SAndroid Build Coastguard Worker */ 345*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 346*0e209d39SAndroid Build Coastguard Worker uidna_labelToASCII_UTF8(const UIDNA *idna, 347*0e209d39SAndroid Build Coastguard Worker const char *label, int32_t length, 348*0e209d39SAndroid Build Coastguard Worker char *dest, int32_t capacity, 349*0e209d39SAndroid Build Coastguard Worker UIDNAInfo *pInfo, UErrorCode *pErrorCode); 350*0e209d39SAndroid Build Coastguard Worker 351*0e209d39SAndroid Build Coastguard Worker /** 352*0e209d39SAndroid Build Coastguard Worker * Converts a single domain name label into its Unicode form for human-readable display. 353*0e209d39SAndroid Build Coastguard Worker * UTF-8 version of uidna_labelToUnicode(), same behavior. 354*0e209d39SAndroid Build Coastguard Worker * 355*0e209d39SAndroid Build Coastguard Worker * @param idna UIDNA instance 356*0e209d39SAndroid Build Coastguard Worker * @param label Input domain name label 357*0e209d39SAndroid Build Coastguard Worker * @param length Label length, or -1 if NUL-terminated 358*0e209d39SAndroid Build Coastguard Worker * @param dest Destination string buffer 359*0e209d39SAndroid Build Coastguard Worker * @param capacity Destination buffer capacity 360*0e209d39SAndroid Build Coastguard Worker * @param pInfo Output container of IDNA processing details. 361*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Standard ICU error code. Its input value must 362*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns 363*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with 364*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.) 365*0e209d39SAndroid Build Coastguard Worker * @return destination string length 366*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 367*0e209d39SAndroid Build Coastguard Worker */ 368*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 369*0e209d39SAndroid Build Coastguard Worker uidna_labelToUnicodeUTF8(const UIDNA *idna, 370*0e209d39SAndroid Build Coastguard Worker const char *label, int32_t length, 371*0e209d39SAndroid Build Coastguard Worker char *dest, int32_t capacity, 372*0e209d39SAndroid Build Coastguard Worker UIDNAInfo *pInfo, UErrorCode *pErrorCode); 373*0e209d39SAndroid Build Coastguard Worker 374*0e209d39SAndroid Build Coastguard Worker /** 375*0e209d39SAndroid Build Coastguard Worker * Converts a whole domain name into its ASCII form for DNS lookup. 376*0e209d39SAndroid Build Coastguard Worker * UTF-8 version of uidna_nameToASCII(), same behavior. 377*0e209d39SAndroid Build Coastguard Worker * 378*0e209d39SAndroid Build Coastguard Worker * @param idna UIDNA instance 379*0e209d39SAndroid Build Coastguard Worker * @param name Input domain name 380*0e209d39SAndroid Build Coastguard Worker * @param length Domain name length, or -1 if NUL-terminated 381*0e209d39SAndroid Build Coastguard Worker * @param dest Destination string buffer 382*0e209d39SAndroid Build Coastguard Worker * @param capacity Destination buffer capacity 383*0e209d39SAndroid Build Coastguard Worker * @param pInfo Output container of IDNA processing details. 384*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Standard ICU error code. Its input value must 385*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns 386*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with 387*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.) 388*0e209d39SAndroid Build Coastguard Worker * @return destination string length 389*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 390*0e209d39SAndroid Build Coastguard Worker */ 391*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 392*0e209d39SAndroid Build Coastguard Worker uidna_nameToASCII_UTF8(const UIDNA *idna, 393*0e209d39SAndroid Build Coastguard Worker const char *name, int32_t length, 394*0e209d39SAndroid Build Coastguard Worker char *dest, int32_t capacity, 395*0e209d39SAndroid Build Coastguard Worker UIDNAInfo *pInfo, UErrorCode *pErrorCode); 396*0e209d39SAndroid Build Coastguard Worker 397*0e209d39SAndroid Build Coastguard Worker /** 398*0e209d39SAndroid Build Coastguard Worker * Converts a whole domain name into its Unicode form for human-readable display. 399*0e209d39SAndroid Build Coastguard Worker * UTF-8 version of uidna_nameToUnicode(), same behavior. 400*0e209d39SAndroid Build Coastguard Worker * 401*0e209d39SAndroid Build Coastguard Worker * @param idna UIDNA instance 402*0e209d39SAndroid Build Coastguard Worker * @param name Input domain name 403*0e209d39SAndroid Build Coastguard Worker * @param length Domain name length, or -1 if NUL-terminated 404*0e209d39SAndroid Build Coastguard Worker * @param dest Destination string buffer 405*0e209d39SAndroid Build Coastguard Worker * @param capacity Destination buffer capacity 406*0e209d39SAndroid Build Coastguard Worker * @param pInfo Output container of IDNA processing details. 407*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Standard ICU error code. Its input value must 408*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns 409*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with 410*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.) 411*0e209d39SAndroid Build Coastguard Worker * @return destination string length 412*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 413*0e209d39SAndroid Build Coastguard Worker */ 414*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 415*0e209d39SAndroid Build Coastguard Worker uidna_nameToUnicodeUTF8(const UIDNA *idna, 416*0e209d39SAndroid Build Coastguard Worker const char *name, int32_t length, 417*0e209d39SAndroid Build Coastguard Worker char *dest, int32_t capacity, 418*0e209d39SAndroid Build Coastguard Worker UIDNAInfo *pInfo, UErrorCode *pErrorCode); 419*0e209d39SAndroid Build Coastguard Worker 420*0e209d39SAndroid Build Coastguard Worker /* 421*0e209d39SAndroid Build Coastguard Worker * IDNA error bit set values. 422*0e209d39SAndroid Build Coastguard Worker * When a domain name or label fails a processing step or does not meet the 423*0e209d39SAndroid Build Coastguard Worker * validity criteria, then one or more of these error bits are set. 424*0e209d39SAndroid Build Coastguard Worker */ 425*0e209d39SAndroid Build Coastguard Worker enum { 426*0e209d39SAndroid Build Coastguard Worker /** 427*0e209d39SAndroid Build Coastguard Worker * A non-final domain name label (or the whole domain name) is empty. 428*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 429*0e209d39SAndroid Build Coastguard Worker */ 430*0e209d39SAndroid Build Coastguard Worker UIDNA_ERROR_EMPTY_LABEL=1, 431*0e209d39SAndroid Build Coastguard Worker /** 432*0e209d39SAndroid Build Coastguard Worker * A domain name label is longer than 63 bytes. 433*0e209d39SAndroid Build Coastguard Worker * (See STD13/RFC1034 3.1. Name space specifications and terminology.) 434*0e209d39SAndroid Build Coastguard Worker * This is only checked in ToASCII operations, and only if the output label is all-ASCII. 435*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 436*0e209d39SAndroid Build Coastguard Worker */ 437*0e209d39SAndroid Build Coastguard Worker UIDNA_ERROR_LABEL_TOO_LONG=2, 438*0e209d39SAndroid Build Coastguard Worker /** 439*0e209d39SAndroid Build Coastguard Worker * A domain name is longer than 255 bytes in its storage form. 440*0e209d39SAndroid Build Coastguard Worker * (See STD13/RFC1034 3.1. Name space specifications and terminology.) 441*0e209d39SAndroid Build Coastguard Worker * This is only checked in ToASCII operations, and only if the output domain name is all-ASCII. 442*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 443*0e209d39SAndroid Build Coastguard Worker */ 444*0e209d39SAndroid Build Coastguard Worker UIDNA_ERROR_DOMAIN_NAME_TOO_LONG=4, 445*0e209d39SAndroid Build Coastguard Worker /** 446*0e209d39SAndroid Build Coastguard Worker * A label starts with a hyphen-minus ('-'). 447*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 448*0e209d39SAndroid Build Coastguard Worker */ 449*0e209d39SAndroid Build Coastguard Worker UIDNA_ERROR_LEADING_HYPHEN=8, 450*0e209d39SAndroid Build Coastguard Worker /** 451*0e209d39SAndroid Build Coastguard Worker * A label ends with a hyphen-minus ('-'). 452*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 453*0e209d39SAndroid Build Coastguard Worker */ 454*0e209d39SAndroid Build Coastguard Worker UIDNA_ERROR_TRAILING_HYPHEN=0x10, 455*0e209d39SAndroid Build Coastguard Worker /** 456*0e209d39SAndroid Build Coastguard Worker * A label contains hyphen-minus ('-') in the third and fourth positions. 457*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 458*0e209d39SAndroid Build Coastguard Worker */ 459*0e209d39SAndroid Build Coastguard Worker UIDNA_ERROR_HYPHEN_3_4=0x20, 460*0e209d39SAndroid Build Coastguard Worker /** 461*0e209d39SAndroid Build Coastguard Worker * A label starts with a combining mark. 462*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 463*0e209d39SAndroid Build Coastguard Worker */ 464*0e209d39SAndroid Build Coastguard Worker UIDNA_ERROR_LEADING_COMBINING_MARK=0x40, 465*0e209d39SAndroid Build Coastguard Worker /** 466*0e209d39SAndroid Build Coastguard Worker * A label or domain name contains disallowed characters. 467*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 468*0e209d39SAndroid Build Coastguard Worker */ 469*0e209d39SAndroid Build Coastguard Worker UIDNA_ERROR_DISALLOWED=0x80, 470*0e209d39SAndroid Build Coastguard Worker /** 471*0e209d39SAndroid Build Coastguard Worker * A label starts with "xn--" but does not contain valid Punycode. 472*0e209d39SAndroid Build Coastguard Worker * That is, an xn-- label failed Punycode decoding. 473*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 474*0e209d39SAndroid Build Coastguard Worker */ 475*0e209d39SAndroid Build Coastguard Worker UIDNA_ERROR_PUNYCODE=0x100, 476*0e209d39SAndroid Build Coastguard Worker /** 477*0e209d39SAndroid Build Coastguard Worker * A label contains a dot=full stop. 478*0e209d39SAndroid Build Coastguard Worker * This can occur in an input string for a single-label function. 479*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 480*0e209d39SAndroid Build Coastguard Worker */ 481*0e209d39SAndroid Build Coastguard Worker UIDNA_ERROR_LABEL_HAS_DOT=0x200, 482*0e209d39SAndroid Build Coastguard Worker /** 483*0e209d39SAndroid Build Coastguard Worker * An ACE label does not contain a valid label string. 484*0e209d39SAndroid Build Coastguard Worker * The label was successfully ACE (Punycode) decoded but the resulting 485*0e209d39SAndroid Build Coastguard Worker * string had severe validation errors. For example, 486*0e209d39SAndroid Build Coastguard Worker * it might contain characters that are not allowed in ACE labels, 487*0e209d39SAndroid Build Coastguard Worker * or it might not be normalized. 488*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 489*0e209d39SAndroid Build Coastguard Worker */ 490*0e209d39SAndroid Build Coastguard Worker UIDNA_ERROR_INVALID_ACE_LABEL=0x400, 491*0e209d39SAndroid Build Coastguard Worker /** 492*0e209d39SAndroid Build Coastguard Worker * A label does not meet the IDNA BiDi requirements (for right-to-left characters). 493*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 494*0e209d39SAndroid Build Coastguard Worker */ 495*0e209d39SAndroid Build Coastguard Worker UIDNA_ERROR_BIDI=0x800, 496*0e209d39SAndroid Build Coastguard Worker /** 497*0e209d39SAndroid Build Coastguard Worker * A label does not meet the IDNA CONTEXTJ requirements. 498*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.6 499*0e209d39SAndroid Build Coastguard Worker */ 500*0e209d39SAndroid Build Coastguard Worker UIDNA_ERROR_CONTEXTJ=0x1000, 501*0e209d39SAndroid Build Coastguard Worker /** 502*0e209d39SAndroid Build Coastguard Worker * A label does not meet the IDNA CONTEXTO requirements for punctuation characters. 503*0e209d39SAndroid Build Coastguard Worker * Some punctuation characters "Would otherwise have been DISALLOWED" 504*0e209d39SAndroid Build Coastguard Worker * but are allowed in certain contexts. (RFC 5892) 505*0e209d39SAndroid Build Coastguard Worker * @stable ICU 49 506*0e209d39SAndroid Build Coastguard Worker */ 507*0e209d39SAndroid Build Coastguard Worker UIDNA_ERROR_CONTEXTO_PUNCTUATION=0x2000, 508*0e209d39SAndroid Build Coastguard Worker /** 509*0e209d39SAndroid Build Coastguard Worker * A label does not meet the IDNA CONTEXTO requirements for digits. 510*0e209d39SAndroid Build Coastguard Worker * Arabic-Indic Digits (U+066x) must not be mixed with Extended Arabic-Indic Digits (U+06Fx). 511*0e209d39SAndroid Build Coastguard Worker * @stable ICU 49 512*0e209d39SAndroid Build Coastguard Worker */ 513*0e209d39SAndroid Build Coastguard Worker UIDNA_ERROR_CONTEXTO_DIGITS=0x4000 514*0e209d39SAndroid Build Coastguard Worker }; 515*0e209d39SAndroid Build Coastguard Worker 516*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 517*0e209d39SAndroid Build Coastguard Worker 518*0e209d39SAndroid Build Coastguard Worker /* IDNA2003 API ------------------------------------------------------------- */ 519*0e209d39SAndroid Build Coastguard Worker 520*0e209d39SAndroid Build Coastguard Worker /** 521*0e209d39SAndroid Build Coastguard Worker * IDNA2003: This function implements the ToASCII operation as defined in the IDNA RFC. 522*0e209d39SAndroid Build Coastguard Worker * This operation is done on <b>single labels</b> before sending it to something that expects 523*0e209d39SAndroid Build Coastguard Worker * ASCII names. A label is an individual part of a domain name. Labels are usually 524*0e209d39SAndroid Build Coastguard Worker * separated by dots; e.g. "www.example.com" is composed of 3 labels "www","example", and "com". 525*0e209d39SAndroid Build Coastguard Worker * 526*0e209d39SAndroid Build Coastguard Worker * IDNA2003 API Overview: 527*0e209d39SAndroid Build Coastguard Worker * 528*0e209d39SAndroid Build Coastguard Worker * The uidna_ API implements the IDNA protocol as defined in the IDNA RFC 529*0e209d39SAndroid Build Coastguard Worker * (http://www.ietf.org/rfc/rfc3490.txt). 530*0e209d39SAndroid Build Coastguard Worker * The RFC defines 2 operations: ToASCII and ToUnicode. Domain name labels 531*0e209d39SAndroid Build Coastguard Worker * containing non-ASCII code points are processed by the 532*0e209d39SAndroid Build Coastguard Worker * ToASCII operation before passing it to resolver libraries. Domain names 533*0e209d39SAndroid Build Coastguard Worker * that are obtained from resolver libraries are processed by the 534*0e209d39SAndroid Build Coastguard Worker * ToUnicode operation before displaying the domain name to the user. 535*0e209d39SAndroid Build Coastguard Worker * IDNA requires that implementations process input strings with Nameprep 536*0e209d39SAndroid Build Coastguard Worker * (http://www.ietf.org/rfc/rfc3491.txt), 537*0e209d39SAndroid Build Coastguard Worker * which is a profile of Stringprep (http://www.ietf.org/rfc/rfc3454.txt), 538*0e209d39SAndroid Build Coastguard Worker * and then with Punycode (http://www.ietf.org/rfc/rfc3492.txt). 539*0e209d39SAndroid Build Coastguard Worker * Implementations of IDNA MUST fully implement Nameprep and Punycode; 540*0e209d39SAndroid Build Coastguard Worker * neither Nameprep nor Punycode are optional. 541*0e209d39SAndroid Build Coastguard Worker * The input and output of ToASCII and ToUnicode operations are Unicode 542*0e209d39SAndroid Build Coastguard Worker * and are designed to be chainable, i.e., applying ToASCII or ToUnicode operations 543*0e209d39SAndroid Build Coastguard Worker * multiple times to an input string will yield the same result as applying the operation 544*0e209d39SAndroid Build Coastguard Worker * once. 545*0e209d39SAndroid Build Coastguard Worker * ToUnicode(ToUnicode(ToUnicode...(ToUnicode(string)))) == ToUnicode(string) 546*0e209d39SAndroid Build Coastguard Worker * ToASCII(ToASCII(ToASCII...(ToASCII(string))) == ToASCII(string). 547*0e209d39SAndroid Build Coastguard Worker * 548*0e209d39SAndroid Build Coastguard Worker * @param src Input UChar array containing label in Unicode. 549*0e209d39SAndroid Build Coastguard Worker * @param srcLength Number of UChars in src, or -1 if NUL-terminated. 550*0e209d39SAndroid Build Coastguard Worker * @param dest Output UChar array with ASCII (ACE encoded) label. 551*0e209d39SAndroid Build Coastguard Worker * @param destCapacity Size of dest. 552*0e209d39SAndroid Build Coastguard Worker * @param options A bit set of options: 553*0e209d39SAndroid Build Coastguard Worker * 554*0e209d39SAndroid Build Coastguard Worker * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points 555*0e209d39SAndroid Build Coastguard Worker * and do not use STD3 ASCII rules 556*0e209d39SAndroid Build Coastguard Worker * If unassigned code points are found the operation fails with 557*0e209d39SAndroid Build Coastguard Worker * U_UNASSIGNED_ERROR error code. 558*0e209d39SAndroid Build Coastguard Worker * 559*0e209d39SAndroid Build Coastguard Worker * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations 560*0e209d39SAndroid Build Coastguard Worker * If this option is set, the unassigned code points are in the input 561*0e209d39SAndroid Build Coastguard Worker * are treated as normal Unicode code points. 562*0e209d39SAndroid Build Coastguard Worker * 563*0e209d39SAndroid Build Coastguard Worker * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions 564*0e209d39SAndroid Build Coastguard Worker * If this option is set and the input does not satisfy STD3 rules, 565*0e209d39SAndroid Build Coastguard Worker * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR 566*0e209d39SAndroid Build Coastguard Worker * 567*0e209d39SAndroid Build Coastguard Worker * @param parseError Pointer to UParseError struct to receive information on position 568*0e209d39SAndroid Build Coastguard Worker * of error if an error is encountered. Can be NULL. 569*0e209d39SAndroid Build Coastguard Worker * @param status ICU in/out error code parameter. 570*0e209d39SAndroid Build Coastguard Worker * U_INVALID_CHAR_FOUND if src contains 571*0e209d39SAndroid Build Coastguard Worker * unmatched single surrogates. 572*0e209d39SAndroid Build Coastguard Worker * U_INDEX_OUTOFBOUNDS_ERROR if src contains 573*0e209d39SAndroid Build Coastguard Worker * too many code points. 574*0e209d39SAndroid Build Coastguard Worker * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough 575*0e209d39SAndroid Build Coastguard Worker * @return The length of the result string, if successful - or in case of a buffer overflow, 576*0e209d39SAndroid Build Coastguard Worker * in which case it will be greater than destCapacity. 577*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. 578*0e209d39SAndroid Build Coastguard Worker */ 579*0e209d39SAndroid Build Coastguard Worker U_DEPRECATED int32_t U_EXPORT2 580*0e209d39SAndroid Build Coastguard Worker uidna_toASCII(const UChar* src, int32_t srcLength, 581*0e209d39SAndroid Build Coastguard Worker UChar* dest, int32_t destCapacity, 582*0e209d39SAndroid Build Coastguard Worker int32_t options, 583*0e209d39SAndroid Build Coastguard Worker UParseError* parseError, 584*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 585*0e209d39SAndroid Build Coastguard Worker 586*0e209d39SAndroid Build Coastguard Worker 587*0e209d39SAndroid Build Coastguard Worker /** 588*0e209d39SAndroid Build Coastguard Worker * IDNA2003: This function implements the ToUnicode operation as defined in the IDNA RFC. 589*0e209d39SAndroid Build Coastguard Worker * This operation is done on <b>single labels</b> before sending it to something that expects 590*0e209d39SAndroid Build Coastguard Worker * Unicode names. A label is an individual part of a domain name. Labels are usually 591*0e209d39SAndroid Build Coastguard Worker * separated by dots; for e.g. "www.example.com" is composed of 3 labels "www","example", and "com". 592*0e209d39SAndroid Build Coastguard Worker * 593*0e209d39SAndroid Build Coastguard Worker * @param src Input UChar array containing ASCII (ACE encoded) label. 594*0e209d39SAndroid Build Coastguard Worker * @param srcLength Number of UChars in src, or -1 if NUL-terminated. 595*0e209d39SAndroid Build Coastguard Worker * @param dest Output Converted UChar array containing Unicode equivalent of label. 596*0e209d39SAndroid Build Coastguard Worker * @param destCapacity Size of dest. 597*0e209d39SAndroid Build Coastguard Worker * @param options A bit set of options: 598*0e209d39SAndroid Build Coastguard Worker * 599*0e209d39SAndroid Build Coastguard Worker * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points 600*0e209d39SAndroid Build Coastguard Worker * and do not use STD3 ASCII rules 601*0e209d39SAndroid Build Coastguard Worker * If unassigned code points are found the operation fails with 602*0e209d39SAndroid Build Coastguard Worker * U_UNASSIGNED_ERROR error code. 603*0e209d39SAndroid Build Coastguard Worker * 604*0e209d39SAndroid Build Coastguard Worker * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations 605*0e209d39SAndroid Build Coastguard Worker * If this option is set, the unassigned code points are in the input 606*0e209d39SAndroid Build Coastguard Worker * are treated as normal Unicode code points. <b> Note: </b> This option is 607*0e209d39SAndroid Build Coastguard Worker * required on toUnicode operation because the RFC mandates 608*0e209d39SAndroid Build Coastguard Worker * verification of decoded ACE input by applying toASCII and comparing 609*0e209d39SAndroid Build Coastguard Worker * its output with source 610*0e209d39SAndroid Build Coastguard Worker * 611*0e209d39SAndroid Build Coastguard Worker * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions 612*0e209d39SAndroid Build Coastguard Worker * If this option is set and the input does not satisfy STD3 rules, 613*0e209d39SAndroid Build Coastguard Worker * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR 614*0e209d39SAndroid Build Coastguard Worker * 615*0e209d39SAndroid Build Coastguard Worker * @param parseError Pointer to UParseError struct to receive information on position 616*0e209d39SAndroid Build Coastguard Worker * of error if an error is encountered. Can be NULL. 617*0e209d39SAndroid Build Coastguard Worker * @param status ICU in/out error code parameter. 618*0e209d39SAndroid Build Coastguard Worker * U_INVALID_CHAR_FOUND if src contains 619*0e209d39SAndroid Build Coastguard Worker * unmatched single surrogates. 620*0e209d39SAndroid Build Coastguard Worker * U_INDEX_OUTOFBOUNDS_ERROR if src contains 621*0e209d39SAndroid Build Coastguard Worker * too many code points. 622*0e209d39SAndroid Build Coastguard Worker * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough 623*0e209d39SAndroid Build Coastguard Worker * @return The length of the result string, if successful - or in case of a buffer overflow, 624*0e209d39SAndroid Build Coastguard Worker * in which case it will be greater than destCapacity. 625*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. 626*0e209d39SAndroid Build Coastguard Worker */ 627*0e209d39SAndroid Build Coastguard Worker U_DEPRECATED int32_t U_EXPORT2 628*0e209d39SAndroid Build Coastguard Worker uidna_toUnicode(const UChar* src, int32_t srcLength, 629*0e209d39SAndroid Build Coastguard Worker UChar* dest, int32_t destCapacity, 630*0e209d39SAndroid Build Coastguard Worker int32_t options, 631*0e209d39SAndroid Build Coastguard Worker UParseError* parseError, 632*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 633*0e209d39SAndroid Build Coastguard Worker 634*0e209d39SAndroid Build Coastguard Worker 635*0e209d39SAndroid Build Coastguard Worker /** 636*0e209d39SAndroid Build Coastguard Worker * IDNA2003: Convenience function that implements the IDNToASCII operation as defined in the IDNA RFC. 637*0e209d39SAndroid Build Coastguard Worker * This operation is done on complete domain names, e.g: "www.example.com". 638*0e209d39SAndroid Build Coastguard Worker * It is important to note that this operation can fail. If it fails, then the input 639*0e209d39SAndroid Build Coastguard Worker * domain name cannot be used as an Internationalized Domain Name and the application 640*0e209d39SAndroid Build Coastguard Worker * should have methods defined to deal with the failure. 641*0e209d39SAndroid Build Coastguard Worker * 642*0e209d39SAndroid Build Coastguard Worker * <b>Note:</b> IDNA RFC specifies that a conformant application should divide a domain name 643*0e209d39SAndroid Build Coastguard Worker * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, 644*0e209d39SAndroid Build Coastguard Worker * and then convert. This function does not offer that level of granularity. The options once 645*0e209d39SAndroid Build Coastguard Worker * set will apply to all labels in the domain name 646*0e209d39SAndroid Build Coastguard Worker * 647*0e209d39SAndroid Build Coastguard Worker * @param src Input UChar array containing IDN in Unicode. 648*0e209d39SAndroid Build Coastguard Worker * @param srcLength Number of UChars in src, or -1 if NUL-terminated. 649*0e209d39SAndroid Build Coastguard Worker * @param dest Output UChar array with ASCII (ACE encoded) IDN. 650*0e209d39SAndroid Build Coastguard Worker * @param destCapacity Size of dest. 651*0e209d39SAndroid Build Coastguard Worker * @param options A bit set of options: 652*0e209d39SAndroid Build Coastguard Worker * 653*0e209d39SAndroid Build Coastguard Worker * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points 654*0e209d39SAndroid Build Coastguard Worker * and do not use STD3 ASCII rules 655*0e209d39SAndroid Build Coastguard Worker * If unassigned code points are found the operation fails with 656*0e209d39SAndroid Build Coastguard Worker * U_UNASSIGNED_CODE_POINT_FOUND error code. 657*0e209d39SAndroid Build Coastguard Worker * 658*0e209d39SAndroid Build Coastguard Worker * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations 659*0e209d39SAndroid Build Coastguard Worker * If this option is set, the unassigned code points are in the input 660*0e209d39SAndroid Build Coastguard Worker * are treated as normal Unicode code points. 661*0e209d39SAndroid Build Coastguard Worker * 662*0e209d39SAndroid Build Coastguard Worker * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions 663*0e209d39SAndroid Build Coastguard Worker * If this option is set and the input does not satisfy STD3 rules, 664*0e209d39SAndroid Build Coastguard Worker * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR 665*0e209d39SAndroid Build Coastguard Worker * 666*0e209d39SAndroid Build Coastguard Worker * @param parseError Pointer to UParseError struct to receive information on position 667*0e209d39SAndroid Build Coastguard Worker * of error if an error is encountered. Can be NULL. 668*0e209d39SAndroid Build Coastguard Worker * @param status ICU in/out error code parameter. 669*0e209d39SAndroid Build Coastguard Worker * U_INVALID_CHAR_FOUND if src contains 670*0e209d39SAndroid Build Coastguard Worker * unmatched single surrogates. 671*0e209d39SAndroid Build Coastguard Worker * U_INDEX_OUTOFBOUNDS_ERROR if src contains 672*0e209d39SAndroid Build Coastguard Worker * too many code points. 673*0e209d39SAndroid Build Coastguard Worker * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough 674*0e209d39SAndroid Build Coastguard Worker * @return The length of the result string, if successful - or in case of a buffer overflow, 675*0e209d39SAndroid Build Coastguard Worker * in which case it will be greater than destCapacity. 676*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. 677*0e209d39SAndroid Build Coastguard Worker */ 678*0e209d39SAndroid Build Coastguard Worker U_DEPRECATED int32_t U_EXPORT2 679*0e209d39SAndroid Build Coastguard Worker uidna_IDNToASCII( const UChar* src, int32_t srcLength, 680*0e209d39SAndroid Build Coastguard Worker UChar* dest, int32_t destCapacity, 681*0e209d39SAndroid Build Coastguard Worker int32_t options, 682*0e209d39SAndroid Build Coastguard Worker UParseError* parseError, 683*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 684*0e209d39SAndroid Build Coastguard Worker 685*0e209d39SAndroid Build Coastguard Worker /** 686*0e209d39SAndroid Build Coastguard Worker * IDNA2003: Convenience function that implements the IDNToUnicode operation as defined in the IDNA RFC. 687*0e209d39SAndroid Build Coastguard Worker * This operation is done on complete domain names, e.g: "www.example.com". 688*0e209d39SAndroid Build Coastguard Worker * 689*0e209d39SAndroid Build Coastguard Worker * <b>Note:</b> IDNA RFC specifies that a conformant application should divide a domain name 690*0e209d39SAndroid Build Coastguard Worker * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, 691*0e209d39SAndroid Build Coastguard Worker * and then convert. This function does not offer that level of granularity. The options once 692*0e209d39SAndroid Build Coastguard Worker * set will apply to all labels in the domain name 693*0e209d39SAndroid Build Coastguard Worker * 694*0e209d39SAndroid Build Coastguard Worker * @param src Input UChar array containing IDN in ASCII (ACE encoded) form. 695*0e209d39SAndroid Build Coastguard Worker * @param srcLength Number of UChars in src, or -1 if NUL-terminated. 696*0e209d39SAndroid Build Coastguard Worker * @param dest Output UChar array containing Unicode equivalent of source IDN. 697*0e209d39SAndroid Build Coastguard Worker * @param destCapacity Size of dest. 698*0e209d39SAndroid Build Coastguard Worker * @param options A bit set of options: 699*0e209d39SAndroid Build Coastguard Worker * 700*0e209d39SAndroid Build Coastguard Worker * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points 701*0e209d39SAndroid Build Coastguard Worker * and do not use STD3 ASCII rules 702*0e209d39SAndroid Build Coastguard Worker * If unassigned code points are found the operation fails with 703*0e209d39SAndroid Build Coastguard Worker * U_UNASSIGNED_CODE_POINT_FOUND error code. 704*0e209d39SAndroid Build Coastguard Worker * 705*0e209d39SAndroid Build Coastguard Worker * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations 706*0e209d39SAndroid Build Coastguard Worker * If this option is set, the unassigned code points are in the input 707*0e209d39SAndroid Build Coastguard Worker * are treated as normal Unicode code points. 708*0e209d39SAndroid Build Coastguard Worker * 709*0e209d39SAndroid Build Coastguard Worker * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions 710*0e209d39SAndroid Build Coastguard Worker * If this option is set and the input does not satisfy STD3 rules, 711*0e209d39SAndroid Build Coastguard Worker * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR 712*0e209d39SAndroid Build Coastguard Worker * 713*0e209d39SAndroid Build Coastguard Worker * @param parseError Pointer to UParseError struct to receive information on position 714*0e209d39SAndroid Build Coastguard Worker * of error if an error is encountered. Can be NULL. 715*0e209d39SAndroid Build Coastguard Worker * @param status ICU in/out error code parameter. 716*0e209d39SAndroid Build Coastguard Worker * U_INVALID_CHAR_FOUND if src contains 717*0e209d39SAndroid Build Coastguard Worker * unmatched single surrogates. 718*0e209d39SAndroid Build Coastguard Worker * U_INDEX_OUTOFBOUNDS_ERROR if src contains 719*0e209d39SAndroid Build Coastguard Worker * too many code points. 720*0e209d39SAndroid Build Coastguard Worker * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough 721*0e209d39SAndroid Build Coastguard Worker * @return The length of the result string, if successful - or in case of a buffer overflow, 722*0e209d39SAndroid Build Coastguard Worker * in which case it will be greater than destCapacity. 723*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. 724*0e209d39SAndroid Build Coastguard Worker */ 725*0e209d39SAndroid Build Coastguard Worker U_DEPRECATED int32_t U_EXPORT2 726*0e209d39SAndroid Build Coastguard Worker uidna_IDNToUnicode( const UChar* src, int32_t srcLength, 727*0e209d39SAndroid Build Coastguard Worker UChar* dest, int32_t destCapacity, 728*0e209d39SAndroid Build Coastguard Worker int32_t options, 729*0e209d39SAndroid Build Coastguard Worker UParseError* parseError, 730*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 731*0e209d39SAndroid Build Coastguard Worker 732*0e209d39SAndroid Build Coastguard Worker /** 733*0e209d39SAndroid Build Coastguard Worker * IDNA2003: Compare two IDN strings for equivalence. 734*0e209d39SAndroid Build Coastguard Worker * This function splits the domain names into labels and compares them. 735*0e209d39SAndroid Build Coastguard Worker * According to IDN RFC, whenever two labels are compared, they are 736*0e209d39SAndroid Build Coastguard Worker * considered equal if and only if their ASCII forms (obtained by 737*0e209d39SAndroid Build Coastguard Worker * applying toASCII) match using an case-insensitive ASCII comparison. 738*0e209d39SAndroid Build Coastguard Worker * Two domain names are considered a match if and only if all labels 739*0e209d39SAndroid Build Coastguard Worker * match regardless of whether label separators match. 740*0e209d39SAndroid Build Coastguard Worker * 741*0e209d39SAndroid Build Coastguard Worker * @param s1 First source string. 742*0e209d39SAndroid Build Coastguard Worker * @param length1 Length of first source string, or -1 if NUL-terminated. 743*0e209d39SAndroid Build Coastguard Worker * 744*0e209d39SAndroid Build Coastguard Worker * @param s2 Second source string. 745*0e209d39SAndroid Build Coastguard Worker * @param length2 Length of second source string, or -1 if NUL-terminated. 746*0e209d39SAndroid Build Coastguard Worker * @param options A bit set of options: 747*0e209d39SAndroid Build Coastguard Worker * 748*0e209d39SAndroid Build Coastguard Worker * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points 749*0e209d39SAndroid Build Coastguard Worker * and do not use STD3 ASCII rules 750*0e209d39SAndroid Build Coastguard Worker * If unassigned code points are found the operation fails with 751*0e209d39SAndroid Build Coastguard Worker * U_UNASSIGNED_CODE_POINT_FOUND error code. 752*0e209d39SAndroid Build Coastguard Worker * 753*0e209d39SAndroid Build Coastguard Worker * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations 754*0e209d39SAndroid Build Coastguard Worker * If this option is set, the unassigned code points are in the input 755*0e209d39SAndroid Build Coastguard Worker * are treated as normal Unicode code points. 756*0e209d39SAndroid Build Coastguard Worker * 757*0e209d39SAndroid Build Coastguard Worker * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions 758*0e209d39SAndroid Build Coastguard Worker * If this option is set and the input does not satisfy STD3 rules, 759*0e209d39SAndroid Build Coastguard Worker * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR 760*0e209d39SAndroid Build Coastguard Worker * 761*0e209d39SAndroid Build Coastguard Worker * @param status ICU error code in/out parameter. 762*0e209d39SAndroid Build Coastguard Worker * Must fulfill U_SUCCESS before the function call. 763*0e209d39SAndroid Build Coastguard Worker * @return <0 or 0 or >0 as usual for string comparisons 764*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA. 765*0e209d39SAndroid Build Coastguard Worker */ 766*0e209d39SAndroid Build Coastguard Worker U_DEPRECATED int32_t U_EXPORT2 767*0e209d39SAndroid Build Coastguard Worker uidna_compare( const UChar *s1, int32_t length1, 768*0e209d39SAndroid Build Coastguard Worker const UChar *s2, int32_t length2, 769*0e209d39SAndroid Build Coastguard Worker int32_t options, 770*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 771*0e209d39SAndroid Build Coastguard Worker 772*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 773*0e209d39SAndroid Build Coastguard Worker 774*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_IDNA */ 775*0e209d39SAndroid Build Coastguard Worker 776*0e209d39SAndroid Build Coastguard Worker #endif 777