1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* 2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ******************************************************************************* 3b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 4103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * Copyright (C) 2003-2012, International Business Machines 5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Corporation and others. All Rights Reserved. 6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru ******************************************************************************* 8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * file name: uidna.h 9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * encoding: US-ASCII 10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * tab size: 8 (not used) 11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * indentation:4 12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 13b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * created on: 2003feb1 14b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * created by: Ram Viswanadha 15b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifndef __UIDNA_H__ 18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define __UIDNA_H__ 19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/utypes.h" 21b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 22b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_IDNA 23b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2427f654740f2a26ad62a5c155af9199af9e69b889claireho#include "unicode/localpointer.h" 25b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/parseerr.h" 2627f654740f2a26ad62a5c155af9199af9e69b889claireho 27b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 28b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * \file 2927f654740f2a26ad62a5c155af9199af9e69b889claireho * \brief C API: Internationalizing Domain Names in Applications (IDNA) 30b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3127f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA2008 is implemented according to UTS #46, see the IDNA C++ class in idna.h. 32b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 3327f654740f2a26ad62a5c155af9199af9e69b889claireho * The C API functions which do take a UIDNA * service object pointer 3427f654740f2a26ad62a5c155af9199af9e69b889claireho * implement UTS #46 and IDNA2008. 3527f654740f2a26ad62a5c155af9199af9e69b889claireho * The C API functions which do not take a service object pointer 3627f654740f2a26ad62a5c155af9199af9e69b889claireho * implement IDNA2003. 37b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 38b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 3927f654740f2a26ad62a5c155af9199af9e69b889claireho/* 4027f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA option bit set values. 41b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 4227f654740f2a26ad62a5c155af9199af9e69b889clairehoenum { 4327f654740f2a26ad62a5c155af9199af9e69b889claireho /** 4427f654740f2a26ad62a5c155af9199af9e69b889claireho * Default options value: None of the other options are set. 45103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * For use in static worker and factory methods. 4627f654740f2a26ad62a5c155af9199af9e69b889claireho * @stable ICU 2.6 4727f654740f2a26ad62a5c155af9199af9e69b889claireho */ 4827f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_DEFAULT=0, 4927f654740f2a26ad62a5c155af9199af9e69b889claireho /** 5027f654740f2a26ad62a5c155af9199af9e69b889claireho * Option to allow unassigned code points in domain names and labels. 51103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * For use in static worker and factory methods. 52103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * <p>This option is ignored by the UTS46 implementation. 5327f654740f2a26ad62a5c155af9199af9e69b889claireho * (UTS #46 disallows unassigned code points.) 5427f654740f2a26ad62a5c155af9199af9e69b889claireho * @stable ICU 2.6 5527f654740f2a26ad62a5c155af9199af9e69b889claireho */ 5627f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_ALLOW_UNASSIGNED=1, 5727f654740f2a26ad62a5c155af9199af9e69b889claireho /** 5827f654740f2a26ad62a5c155af9199af9e69b889claireho * Option to check whether the input conforms to the STD3 ASCII rules, 5927f654740f2a26ad62a5c155af9199af9e69b889claireho * for example the restriction of labels to LDH characters 6027f654740f2a26ad62a5c155af9199af9e69b889claireho * (ASCII Letters, Digits and Hyphen-Minus). 61103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * For use in static worker and factory methods. 6227f654740f2a26ad62a5c155af9199af9e69b889claireho * @stable ICU 2.6 6327f654740f2a26ad62a5c155af9199af9e69b889claireho */ 6427f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_USE_STD3_RULES=2, 6527f654740f2a26ad62a5c155af9199af9e69b889claireho /** 6627f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA option to check for whether the input conforms to the BiDi rules. 67103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * For use in static worker and factory methods. 68103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * <p>This option is ignored by the IDNA2003 implementation. 6927f654740f2a26ad62a5c155af9199af9e69b889claireho * (IDNA2003 always performs a BiDi check.) 70103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 7127f654740f2a26ad62a5c155af9199af9e69b889claireho */ 7227f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_CHECK_BIDI=4, 7327f654740f2a26ad62a5c155af9199af9e69b889claireho /** 7427f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA option to check for whether the input conforms to the CONTEXTJ rules. 75103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * For use in static worker and factory methods. 76103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * <p>This option is ignored by the IDNA2003 implementation. 7727f654740f2a26ad62a5c155af9199af9e69b889claireho * (The CONTEXTJ check is new in IDNA2008.) 78103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 7927f654740f2a26ad62a5c155af9199af9e69b889claireho */ 8027f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_CHECK_CONTEXTJ=8, 8127f654740f2a26ad62a5c155af9199af9e69b889claireho /** 8227f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA option for nontransitional processing in ToASCII(). 83103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * For use in static worker and factory methods. 84103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * <p>By default, ToASCII() uses transitional processing. 85103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * <p>This option is ignored by the IDNA2003 implementation. 8627f654740f2a26ad62a5c155af9199af9e69b889claireho * (This is only relevant for compatibility of newer IDNA implementations with IDNA2003.) 87103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 8827f654740f2a26ad62a5c155af9199af9e69b889claireho */ 8927f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_NONTRANSITIONAL_TO_ASCII=0x10, 9027f654740f2a26ad62a5c155af9199af9e69b889claireho /** 9127f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA option for nontransitional processing in ToUnicode(). 92103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * For use in static worker and factory methods. 93103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * <p>By default, ToUnicode() uses transitional processing. 94103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * <p>This option is ignored by the IDNA2003 implementation. 9527f654740f2a26ad62a5c155af9199af9e69b889claireho * (This is only relevant for compatibility of newer IDNA implementations with IDNA2003.) 96103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 9727f654740f2a26ad62a5c155af9199af9e69b889claireho */ 98103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius UIDNA_NONTRANSITIONAL_TO_UNICODE=0x20, 99103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_DRAFT_API 100103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius /** 101103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * IDNA option to check for whether the input conforms to the CONTEXTO rules. 102103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * For use in static worker and factory methods. 103103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * <p>This option is ignored by the IDNA2003 implementation. 104103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * (The CONTEXTO check is new in IDNA2008.) 105103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * <p>This is for use by registries for IDNA2008 conformance. 106103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * UTS #46 does not require the CONTEXTO check. 107103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @draft ICU 49 108103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius */ 109103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius UIDNA_CHECK_CONTEXTO=0x40 110103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif /* U_HIDE_DRAFT_API */ 11127f654740f2a26ad62a5c155af9199af9e69b889claireho}; 11227f654740f2a26ad62a5c155af9199af9e69b889claireho 11327f654740f2a26ad62a5c155af9199af9e69b889claireho/** 11427f654740f2a26ad62a5c155af9199af9e69b889claireho * Opaque C service object type for the new IDNA API. 115103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 11727f654740f2a26ad62a5c155af9199af9e69b889clairehostruct UIDNA; 118103e9ffba2cba345d0078eb8b8db33249f81840aCraig Corneliustypedef struct UIDNA UIDNA; /**< C typedef for struct UIDNA. @stable ICU 4.6 */ 11927f654740f2a26ad62a5c155af9199af9e69b889claireho 12027f654740f2a26ad62a5c155af9199af9e69b889claireho/** 12127f654740f2a26ad62a5c155af9199af9e69b889claireho * Returns a UIDNA instance which implements UTS #46. 12227f654740f2a26ad62a5c155af9199af9e69b889claireho * Returns an unmodifiable instance, owned by the caller. 12327f654740f2a26ad62a5c155af9199af9e69b889claireho * Cache it for multiple operations, and uidna_close() it when done. 12427f654740f2a26ad62a5c155af9199af9e69b889claireho * The instance is thread-safe, that is, it can be used concurrently. 12527f654740f2a26ad62a5c155af9199af9e69b889claireho * 12627f654740f2a26ad62a5c155af9199af9e69b889claireho * For details about the UTS #46 implementation see the IDNA C++ class in idna.h. 12727f654740f2a26ad62a5c155af9199af9e69b889claireho * 12827f654740f2a26ad62a5c155af9199af9e69b889claireho * @param options Bit set to modify the processing and error checking. 12927f654740f2a26ad62a5c155af9199af9e69b889claireho * See option bit set values in uidna.h. 13027f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must 13127f654740f2a26ad62a5c155af9199af9e69b889claireho * pass the U_SUCCESS() test, or else the function returns 13227f654740f2a26ad62a5c155af9199af9e69b889claireho * immediately. Check for U_FAILURE() on output or use with 13327f654740f2a26ad62a5c155af9199af9e69b889claireho * function chaining. (See User Guide for details.) 13427f654740f2a26ad62a5c155af9199af9e69b889claireho * @return the UTS #46 UIDNA instance, if successful 135103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 13627f654740f2a26ad62a5c155af9199af9e69b889claireho */ 13754dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE UIDNA * U_EXPORT2 13827f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_openUTS46(uint32_t options, UErrorCode *pErrorCode); 13927f654740f2a26ad62a5c155af9199af9e69b889claireho 14027f654740f2a26ad62a5c155af9199af9e69b889claireho/** 14127f654740f2a26ad62a5c155af9199af9e69b889claireho * Closes a UIDNA instance. 14227f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance to be closed 143103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 14554dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE void U_EXPORT2 14627f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_close(UIDNA *idna); 14727f654740f2a26ad62a5c155af9199af9e69b889claireho 14827f654740f2a26ad62a5c155af9199af9e69b889claireho#if U_SHOW_CPLUSPLUS_API 14927f654740f2a26ad62a5c155af9199af9e69b889claireho 15027f654740f2a26ad62a5c155af9199af9e69b889clairehoU_NAMESPACE_BEGIN 151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 15327f654740f2a26ad62a5c155af9199af9e69b889claireho * \class LocalUIDNAPointer 15427f654740f2a26ad62a5c155af9199af9e69b889claireho * "Smart pointer" class, closes a UIDNA via uidna_close(). 15527f654740f2a26ad62a5c155af9199af9e69b889claireho * For most methods see the LocalPointerBase base class. 15627f654740f2a26ad62a5c155af9199af9e69b889claireho * 15727f654740f2a26ad62a5c155af9199af9e69b889claireho * @see LocalPointerBase 15827f654740f2a26ad62a5c155af9199af9e69b889claireho * @see LocalPointer 159103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 16027f654740f2a26ad62a5c155af9199af9e69b889claireho */ 16127f654740f2a26ad62a5c155af9199af9e69b889clairehoU_DEFINE_LOCAL_OPEN_POINTER(LocalUIDNAPointer, UIDNA, uidna_close); 16227f654740f2a26ad62a5c155af9199af9e69b889claireho 16327f654740f2a26ad62a5c155af9199af9e69b889clairehoU_NAMESPACE_END 16427f654740f2a26ad62a5c155af9199af9e69b889claireho 16527f654740f2a26ad62a5c155af9199af9e69b889claireho#endif 16627f654740f2a26ad62a5c155af9199af9e69b889claireho 16727f654740f2a26ad62a5c155af9199af9e69b889claireho/** 16827f654740f2a26ad62a5c155af9199af9e69b889claireho * Output container for IDNA processing errors. 16927f654740f2a26ad62a5c155af9199af9e69b889claireho * Initialize with UIDNA_INFO_INITIALIZER: 17027f654740f2a26ad62a5c155af9199af9e69b889claireho * \code 17127f654740f2a26ad62a5c155af9199af9e69b889claireho * UIDNAInfo info = UIDNA_INFO_INITIALIZER; 17227f654740f2a26ad62a5c155af9199af9e69b889claireho * int32_t length = uidna_nameToASCII(..., &info, &errorCode); 17327f654740f2a26ad62a5c155af9199af9e69b889claireho * if(U_SUCCESS(errorCode) && info.errors!=0) { ... } 17427f654740f2a26ad62a5c155af9199af9e69b889claireho * \endcode 175103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 17627f654740f2a26ad62a5c155af9199af9e69b889claireho */ 17754dcd9b6a06071f647dac967e9e267abb9410720Craig Corneliustypedef struct UIDNAInfo { 178103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius /** sizeof(UIDNAInfo) @stable ICU 4.6 */ 17927f654740f2a26ad62a5c155af9199af9e69b889claireho int16_t size; 18027f654740f2a26ad62a5c155af9199af9e69b889claireho /** 18127f654740f2a26ad62a5c155af9199af9e69b889claireho * Set to TRUE if transitional and nontransitional processing produce different results. 18227f654740f2a26ad62a5c155af9199af9e69b889claireho * For details see C++ IDNAInfo::isTransitionalDifferent(). 183103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 18427f654740f2a26ad62a5c155af9199af9e69b889claireho */ 18527f654740f2a26ad62a5c155af9199af9e69b889claireho UBool isTransitionalDifferent; 18627f654740f2a26ad62a5c155af9199af9e69b889claireho UBool reservedB3; /**< Reserved field, do not use. @internal */ 18727f654740f2a26ad62a5c155af9199af9e69b889claireho /** 18827f654740f2a26ad62a5c155af9199af9e69b889claireho * Bit set indicating IDNA processing errors. 0 if no errors. 18927f654740f2a26ad62a5c155af9199af9e69b889claireho * See UIDNA_ERROR_... constants. 190103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 19127f654740f2a26ad62a5c155af9199af9e69b889claireho */ 19227f654740f2a26ad62a5c155af9199af9e69b889claireho uint32_t errors; 19327f654740f2a26ad62a5c155af9199af9e69b889claireho int32_t reservedI2; /**< Reserved field, do not use. @internal */ 19427f654740f2a26ad62a5c155af9199af9e69b889claireho int32_t reservedI3; /**< Reserved field, do not use. @internal */ 19554dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius} UIDNAInfo; 19627f654740f2a26ad62a5c155af9199af9e69b889claireho 19727f654740f2a26ad62a5c155af9199af9e69b889claireho/** 19827f654740f2a26ad62a5c155af9199af9e69b889claireho * Static initializer for a UIDNAInfo struct. 199103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 20027f654740f2a26ad62a5c155af9199af9e69b889claireho */ 20127f654740f2a26ad62a5c155af9199af9e69b889claireho#define UIDNA_INFO_INITIALIZER { \ 20227f654740f2a26ad62a5c155af9199af9e69b889claireho (int16_t)sizeof(UIDNAInfo), \ 20327f654740f2a26ad62a5c155af9199af9e69b889claireho FALSE, FALSE, \ 20427f654740f2a26ad62a5c155af9199af9e69b889claireho 0, 0, 0 } 20527f654740f2a26ad62a5c155af9199af9e69b889claireho 20627f654740f2a26ad62a5c155af9199af9e69b889claireho/** 20727f654740f2a26ad62a5c155af9199af9e69b889claireho * Converts a single domain name label into its ASCII form for DNS lookup. 20827f654740f2a26ad62a5c155af9199af9e69b889claireho * If any processing step fails, then pInfo->errors will be non-zero and 20927f654740f2a26ad62a5c155af9199af9e69b889claireho * the result might not be an ASCII string. 21027f654740f2a26ad62a5c155af9199af9e69b889claireho * The label might be modified according to the types of errors. 21127f654740f2a26ad62a5c155af9199af9e69b889claireho * Labels with severe errors will be left in (or turned into) their Unicode form. 21227f654740f2a26ad62a5c155af9199af9e69b889claireho * 21327f654740f2a26ad62a5c155af9199af9e69b889claireho * The UErrorCode indicates an error only in exceptional cases, 21427f654740f2a26ad62a5c155af9199af9e69b889claireho * such as a U_MEMORY_ALLOCATION_ERROR. 21527f654740f2a26ad62a5c155af9199af9e69b889claireho * 21627f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance 21727f654740f2a26ad62a5c155af9199af9e69b889claireho * @param label Input domain name label 21827f654740f2a26ad62a5c155af9199af9e69b889claireho * @param length Label length, or -1 if NUL-terminated 21927f654740f2a26ad62a5c155af9199af9e69b889claireho * @param dest Destination string buffer 22027f654740f2a26ad62a5c155af9199af9e69b889claireho * @param capacity Destination buffer capacity 22127f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pInfo Output container of IDNA processing details. 22227f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must 22327f654740f2a26ad62a5c155af9199af9e69b889claireho * pass the U_SUCCESS() test, or else the function returns 22427f654740f2a26ad62a5c155af9199af9e69b889claireho * immediately. Check for U_FAILURE() on output or use with 22527f654740f2a26ad62a5c155af9199af9e69b889claireho * function chaining. (See User Guide for details.) 22627f654740f2a26ad62a5c155af9199af9e69b889claireho * @return destination string length 227103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 22827f654740f2a26ad62a5c155af9199af9e69b889claireho */ 22954dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE int32_t U_EXPORT2 23027f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_labelToASCII(const UIDNA *idna, 23127f654740f2a26ad62a5c155af9199af9e69b889claireho const UChar *label, int32_t length, 23227f654740f2a26ad62a5c155af9199af9e69b889claireho UChar *dest, int32_t capacity, 23327f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNAInfo *pInfo, UErrorCode *pErrorCode); 23427f654740f2a26ad62a5c155af9199af9e69b889claireho 23527f654740f2a26ad62a5c155af9199af9e69b889claireho/** 23627f654740f2a26ad62a5c155af9199af9e69b889claireho * Converts a single domain name label into its Unicode form for human-readable display. 23727f654740f2a26ad62a5c155af9199af9e69b889claireho * If any processing step fails, then pInfo->errors will be non-zero. 23827f654740f2a26ad62a5c155af9199af9e69b889claireho * The label might be modified according to the types of errors. 23927f654740f2a26ad62a5c155af9199af9e69b889claireho * 24027f654740f2a26ad62a5c155af9199af9e69b889claireho * The UErrorCode indicates an error only in exceptional cases, 24127f654740f2a26ad62a5c155af9199af9e69b889claireho * such as a U_MEMORY_ALLOCATION_ERROR. 24227f654740f2a26ad62a5c155af9199af9e69b889claireho * 24327f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance 24427f654740f2a26ad62a5c155af9199af9e69b889claireho * @param label Input domain name label 24527f654740f2a26ad62a5c155af9199af9e69b889claireho * @param length Label length, or -1 if NUL-terminated 24627f654740f2a26ad62a5c155af9199af9e69b889claireho * @param dest Destination string buffer 24727f654740f2a26ad62a5c155af9199af9e69b889claireho * @param capacity Destination buffer capacity 24827f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pInfo Output container of IDNA processing details. 24927f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must 25027f654740f2a26ad62a5c155af9199af9e69b889claireho * pass the U_SUCCESS() test, or else the function returns 25127f654740f2a26ad62a5c155af9199af9e69b889claireho * immediately. Check for U_FAILURE() on output or use with 25227f654740f2a26ad62a5c155af9199af9e69b889claireho * function chaining. (See User Guide for details.) 25327f654740f2a26ad62a5c155af9199af9e69b889claireho * @return destination string length 254103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 25527f654740f2a26ad62a5c155af9199af9e69b889claireho */ 25654dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE int32_t U_EXPORT2 25727f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_labelToUnicode(const UIDNA *idna, 25827f654740f2a26ad62a5c155af9199af9e69b889claireho const UChar *label, int32_t length, 25927f654740f2a26ad62a5c155af9199af9e69b889claireho UChar *dest, int32_t capacity, 26027f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNAInfo *pInfo, UErrorCode *pErrorCode); 26127f654740f2a26ad62a5c155af9199af9e69b889claireho 26227f654740f2a26ad62a5c155af9199af9e69b889claireho/** 26327f654740f2a26ad62a5c155af9199af9e69b889claireho * Converts a whole domain name into its ASCII form for DNS lookup. 26427f654740f2a26ad62a5c155af9199af9e69b889claireho * If any processing step fails, then pInfo->errors will be non-zero and 26527f654740f2a26ad62a5c155af9199af9e69b889claireho * the result might not be an ASCII string. 26627f654740f2a26ad62a5c155af9199af9e69b889claireho * The domain name might be modified according to the types of errors. 26727f654740f2a26ad62a5c155af9199af9e69b889claireho * Labels with severe errors will be left in (or turned into) their Unicode form. 26827f654740f2a26ad62a5c155af9199af9e69b889claireho * 26927f654740f2a26ad62a5c155af9199af9e69b889claireho * The UErrorCode indicates an error only in exceptional cases, 27027f654740f2a26ad62a5c155af9199af9e69b889claireho * such as a U_MEMORY_ALLOCATION_ERROR. 27127f654740f2a26ad62a5c155af9199af9e69b889claireho * 27227f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance 27327f654740f2a26ad62a5c155af9199af9e69b889claireho * @param name Input domain name 27427f654740f2a26ad62a5c155af9199af9e69b889claireho * @param length Domain name length, or -1 if NUL-terminated 27527f654740f2a26ad62a5c155af9199af9e69b889claireho * @param dest Destination string buffer 27627f654740f2a26ad62a5c155af9199af9e69b889claireho * @param capacity Destination buffer capacity 27727f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pInfo Output container of IDNA processing details. 27827f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must 27927f654740f2a26ad62a5c155af9199af9e69b889claireho * pass the U_SUCCESS() test, or else the function returns 28027f654740f2a26ad62a5c155af9199af9e69b889claireho * immediately. Check for U_FAILURE() on output or use with 28127f654740f2a26ad62a5c155af9199af9e69b889claireho * function chaining. (See User Guide for details.) 28227f654740f2a26ad62a5c155af9199af9e69b889claireho * @return destination string length 283103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 28427f654740f2a26ad62a5c155af9199af9e69b889claireho */ 28554dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE int32_t U_EXPORT2 28627f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_nameToASCII(const UIDNA *idna, 28727f654740f2a26ad62a5c155af9199af9e69b889claireho const UChar *name, int32_t length, 28827f654740f2a26ad62a5c155af9199af9e69b889claireho UChar *dest, int32_t capacity, 28927f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNAInfo *pInfo, UErrorCode *pErrorCode); 29027f654740f2a26ad62a5c155af9199af9e69b889claireho 29127f654740f2a26ad62a5c155af9199af9e69b889claireho/** 29227f654740f2a26ad62a5c155af9199af9e69b889claireho * Converts a whole domain name into its Unicode form for human-readable display. 29327f654740f2a26ad62a5c155af9199af9e69b889claireho * If any processing step fails, then pInfo->errors will be non-zero. 29427f654740f2a26ad62a5c155af9199af9e69b889claireho * The domain name might be modified according to the types of errors. 29527f654740f2a26ad62a5c155af9199af9e69b889claireho * 29627f654740f2a26ad62a5c155af9199af9e69b889claireho * The UErrorCode indicates an error only in exceptional cases, 29727f654740f2a26ad62a5c155af9199af9e69b889claireho * such as a U_MEMORY_ALLOCATION_ERROR. 29827f654740f2a26ad62a5c155af9199af9e69b889claireho * 29927f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance 30027f654740f2a26ad62a5c155af9199af9e69b889claireho * @param name Input domain name 30127f654740f2a26ad62a5c155af9199af9e69b889claireho * @param length Domain name length, or -1 if NUL-terminated 30227f654740f2a26ad62a5c155af9199af9e69b889claireho * @param dest Destination string buffer 30327f654740f2a26ad62a5c155af9199af9e69b889claireho * @param capacity Destination buffer capacity 30427f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pInfo Output container of IDNA processing details. 30527f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must 30627f654740f2a26ad62a5c155af9199af9e69b889claireho * pass the U_SUCCESS() test, or else the function returns 30727f654740f2a26ad62a5c155af9199af9e69b889claireho * immediately. Check for U_FAILURE() on output or use with 30827f654740f2a26ad62a5c155af9199af9e69b889claireho * function chaining. (See User Guide for details.) 30927f654740f2a26ad62a5c155af9199af9e69b889claireho * @return destination string length 310103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 31127f654740f2a26ad62a5c155af9199af9e69b889claireho */ 31254dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE int32_t U_EXPORT2 31327f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_nameToUnicode(const UIDNA *idna, 31427f654740f2a26ad62a5c155af9199af9e69b889claireho const UChar *name, int32_t length, 31527f654740f2a26ad62a5c155af9199af9e69b889claireho UChar *dest, int32_t capacity, 31627f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNAInfo *pInfo, UErrorCode *pErrorCode); 31727f654740f2a26ad62a5c155af9199af9e69b889claireho 31827f654740f2a26ad62a5c155af9199af9e69b889claireho/* UTF-8 versions of the processing methods --------------------------------- */ 31927f654740f2a26ad62a5c155af9199af9e69b889claireho 32027f654740f2a26ad62a5c155af9199af9e69b889claireho/** 32127f654740f2a26ad62a5c155af9199af9e69b889claireho * Converts a single domain name label into its ASCII form for DNS lookup. 32227f654740f2a26ad62a5c155af9199af9e69b889claireho * UTF-8 version of uidna_labelToASCII(), same behavior. 32327f654740f2a26ad62a5c155af9199af9e69b889claireho * 32427f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance 32527f654740f2a26ad62a5c155af9199af9e69b889claireho * @param label Input domain name label 32627f654740f2a26ad62a5c155af9199af9e69b889claireho * @param length Label length, or -1 if NUL-terminated 32727f654740f2a26ad62a5c155af9199af9e69b889claireho * @param dest Destination string buffer 32827f654740f2a26ad62a5c155af9199af9e69b889claireho * @param capacity Destination buffer capacity 32927f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pInfo Output container of IDNA processing details. 33027f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must 33127f654740f2a26ad62a5c155af9199af9e69b889claireho * pass the U_SUCCESS() test, or else the function returns 33227f654740f2a26ad62a5c155af9199af9e69b889claireho * immediately. Check for U_FAILURE() on output or use with 33327f654740f2a26ad62a5c155af9199af9e69b889claireho * function chaining. (See User Guide for details.) 33427f654740f2a26ad62a5c155af9199af9e69b889claireho * @return destination string length 335103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 33627f654740f2a26ad62a5c155af9199af9e69b889claireho */ 33754dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE int32_t U_EXPORT2 33827f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_labelToASCII_UTF8(const UIDNA *idna, 33927f654740f2a26ad62a5c155af9199af9e69b889claireho const char *label, int32_t length, 34027f654740f2a26ad62a5c155af9199af9e69b889claireho char *dest, int32_t capacity, 34127f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNAInfo *pInfo, UErrorCode *pErrorCode); 34227f654740f2a26ad62a5c155af9199af9e69b889claireho 34327f654740f2a26ad62a5c155af9199af9e69b889claireho/** 34427f654740f2a26ad62a5c155af9199af9e69b889claireho * Converts a single domain name label into its Unicode form for human-readable display. 34527f654740f2a26ad62a5c155af9199af9e69b889claireho * UTF-8 version of uidna_labelToUnicode(), same behavior. 34627f654740f2a26ad62a5c155af9199af9e69b889claireho * 34727f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance 34827f654740f2a26ad62a5c155af9199af9e69b889claireho * @param label Input domain name label 34927f654740f2a26ad62a5c155af9199af9e69b889claireho * @param length Label length, or -1 if NUL-terminated 35027f654740f2a26ad62a5c155af9199af9e69b889claireho * @param dest Destination string buffer 35127f654740f2a26ad62a5c155af9199af9e69b889claireho * @param capacity Destination buffer capacity 35227f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pInfo Output container of IDNA processing details. 35327f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must 35427f654740f2a26ad62a5c155af9199af9e69b889claireho * pass the U_SUCCESS() test, or else the function returns 35527f654740f2a26ad62a5c155af9199af9e69b889claireho * immediately. Check for U_FAILURE() on output or use with 35627f654740f2a26ad62a5c155af9199af9e69b889claireho * function chaining. (See User Guide for details.) 35727f654740f2a26ad62a5c155af9199af9e69b889claireho * @return destination string length 358103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 35927f654740f2a26ad62a5c155af9199af9e69b889claireho */ 36054dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE int32_t U_EXPORT2 36127f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_labelToUnicodeUTF8(const UIDNA *idna, 36227f654740f2a26ad62a5c155af9199af9e69b889claireho const char *label, int32_t length, 36327f654740f2a26ad62a5c155af9199af9e69b889claireho char *dest, int32_t capacity, 36427f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNAInfo *pInfo, UErrorCode *pErrorCode); 36527f654740f2a26ad62a5c155af9199af9e69b889claireho 36627f654740f2a26ad62a5c155af9199af9e69b889claireho/** 36727f654740f2a26ad62a5c155af9199af9e69b889claireho * Converts a whole domain name into its ASCII form for DNS lookup. 36827f654740f2a26ad62a5c155af9199af9e69b889claireho * UTF-8 version of uidna_nameToASCII(), same behavior. 36927f654740f2a26ad62a5c155af9199af9e69b889claireho * 37027f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance 37127f654740f2a26ad62a5c155af9199af9e69b889claireho * @param name Input domain name 37227f654740f2a26ad62a5c155af9199af9e69b889claireho * @param length Domain name length, or -1 if NUL-terminated 37327f654740f2a26ad62a5c155af9199af9e69b889claireho * @param dest Destination string buffer 37427f654740f2a26ad62a5c155af9199af9e69b889claireho * @param capacity Destination buffer capacity 37527f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pInfo Output container of IDNA processing details. 37627f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must 37727f654740f2a26ad62a5c155af9199af9e69b889claireho * pass the U_SUCCESS() test, or else the function returns 37827f654740f2a26ad62a5c155af9199af9e69b889claireho * immediately. Check for U_FAILURE() on output or use with 37927f654740f2a26ad62a5c155af9199af9e69b889claireho * function chaining. (See User Guide for details.) 38027f654740f2a26ad62a5c155af9199af9e69b889claireho * @return destination string length 381103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 38227f654740f2a26ad62a5c155af9199af9e69b889claireho */ 38354dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE int32_t U_EXPORT2 38427f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_nameToASCII_UTF8(const UIDNA *idna, 38527f654740f2a26ad62a5c155af9199af9e69b889claireho const char *name, int32_t length, 38627f654740f2a26ad62a5c155af9199af9e69b889claireho char *dest, int32_t capacity, 38727f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNAInfo *pInfo, UErrorCode *pErrorCode); 38827f654740f2a26ad62a5c155af9199af9e69b889claireho 38927f654740f2a26ad62a5c155af9199af9e69b889claireho/** 39027f654740f2a26ad62a5c155af9199af9e69b889claireho * Converts a whole domain name into its Unicode form for human-readable display. 39127f654740f2a26ad62a5c155af9199af9e69b889claireho * UTF-8 version of uidna_nameToUnicode(), same behavior. 39227f654740f2a26ad62a5c155af9199af9e69b889claireho * 39327f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance 39427f654740f2a26ad62a5c155af9199af9e69b889claireho * @param name Input domain name 39527f654740f2a26ad62a5c155af9199af9e69b889claireho * @param length Domain name length, or -1 if NUL-terminated 39627f654740f2a26ad62a5c155af9199af9e69b889claireho * @param dest Destination string buffer 39727f654740f2a26ad62a5c155af9199af9e69b889claireho * @param capacity Destination buffer capacity 39827f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pInfo Output container of IDNA processing details. 39927f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must 40027f654740f2a26ad62a5c155af9199af9e69b889claireho * pass the U_SUCCESS() test, or else the function returns 40127f654740f2a26ad62a5c155af9199af9e69b889claireho * immediately. Check for U_FAILURE() on output or use with 40227f654740f2a26ad62a5c155af9199af9e69b889claireho * function chaining. (See User Guide for details.) 40327f654740f2a26ad62a5c155af9199af9e69b889claireho * @return destination string length 404103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 40527f654740f2a26ad62a5c155af9199af9e69b889claireho */ 40654dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE int32_t U_EXPORT2 40727f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_nameToUnicodeUTF8(const UIDNA *idna, 40827f654740f2a26ad62a5c155af9199af9e69b889claireho const char *name, int32_t length, 40927f654740f2a26ad62a5c155af9199af9e69b889claireho char *dest, int32_t capacity, 41027f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNAInfo *pInfo, UErrorCode *pErrorCode); 41127f654740f2a26ad62a5c155af9199af9e69b889claireho 41227f654740f2a26ad62a5c155af9199af9e69b889claireho/* 41327f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA error bit set values. 41427f654740f2a26ad62a5c155af9199af9e69b889claireho * When a domain name or label fails a processing step or does not meet the 41527f654740f2a26ad62a5c155af9199af9e69b889claireho * validity criteria, then one or more of these error bits are set. 41627f654740f2a26ad62a5c155af9199af9e69b889claireho */ 41727f654740f2a26ad62a5c155af9199af9e69b889clairehoenum { 41827f654740f2a26ad62a5c155af9199af9e69b889claireho /** 41927f654740f2a26ad62a5c155af9199af9e69b889claireho * A non-final domain name label (or the whole domain name) is empty. 420103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 42127f654740f2a26ad62a5c155af9199af9e69b889claireho */ 42227f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_ERROR_EMPTY_LABEL=1, 42327f654740f2a26ad62a5c155af9199af9e69b889claireho /** 42427f654740f2a26ad62a5c155af9199af9e69b889claireho * A domain name label is longer than 63 bytes. 42527f654740f2a26ad62a5c155af9199af9e69b889claireho * (See STD13/RFC1034 3.1. Name space specifications and terminology.) 42627f654740f2a26ad62a5c155af9199af9e69b889claireho * This is only checked in ToASCII operations, and only if the output label is all-ASCII. 427103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 42827f654740f2a26ad62a5c155af9199af9e69b889claireho */ 42927f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_ERROR_LABEL_TOO_LONG=2, 43027f654740f2a26ad62a5c155af9199af9e69b889claireho /** 43127f654740f2a26ad62a5c155af9199af9e69b889claireho * A domain name is longer than 255 bytes in its storage form. 43227f654740f2a26ad62a5c155af9199af9e69b889claireho * (See STD13/RFC1034 3.1. Name space specifications and terminology.) 43327f654740f2a26ad62a5c155af9199af9e69b889claireho * This is only checked in ToASCII operations, and only if the output domain name is all-ASCII. 434103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 43527f654740f2a26ad62a5c155af9199af9e69b889claireho */ 43627f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_ERROR_DOMAIN_NAME_TOO_LONG=4, 43727f654740f2a26ad62a5c155af9199af9e69b889claireho /** 43827f654740f2a26ad62a5c155af9199af9e69b889claireho * A label starts with a hyphen-minus ('-'). 439103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 44027f654740f2a26ad62a5c155af9199af9e69b889claireho */ 44127f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_ERROR_LEADING_HYPHEN=8, 44227f654740f2a26ad62a5c155af9199af9e69b889claireho /** 44327f654740f2a26ad62a5c155af9199af9e69b889claireho * A label ends with a hyphen-minus ('-'). 444103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 44527f654740f2a26ad62a5c155af9199af9e69b889claireho */ 44627f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_ERROR_TRAILING_HYPHEN=0x10, 44727f654740f2a26ad62a5c155af9199af9e69b889claireho /** 44827f654740f2a26ad62a5c155af9199af9e69b889claireho * A label contains hyphen-minus ('-') in the third and fourth positions. 449103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 45027f654740f2a26ad62a5c155af9199af9e69b889claireho */ 45127f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_ERROR_HYPHEN_3_4=0x20, 45227f654740f2a26ad62a5c155af9199af9e69b889claireho /** 45327f654740f2a26ad62a5c155af9199af9e69b889claireho * A label starts with a combining mark. 454103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 45527f654740f2a26ad62a5c155af9199af9e69b889claireho */ 45627f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_ERROR_LEADING_COMBINING_MARK=0x40, 45727f654740f2a26ad62a5c155af9199af9e69b889claireho /** 45827f654740f2a26ad62a5c155af9199af9e69b889claireho * A label or domain name contains disallowed characters. 459103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 46027f654740f2a26ad62a5c155af9199af9e69b889claireho */ 46127f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_ERROR_DISALLOWED=0x80, 46227f654740f2a26ad62a5c155af9199af9e69b889claireho /** 46327f654740f2a26ad62a5c155af9199af9e69b889claireho * A label starts with "xn--" but does not contain valid Punycode. 46427f654740f2a26ad62a5c155af9199af9e69b889claireho * That is, an xn-- label failed Punycode decoding. 465103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 46627f654740f2a26ad62a5c155af9199af9e69b889claireho */ 46727f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_ERROR_PUNYCODE=0x100, 46827f654740f2a26ad62a5c155af9199af9e69b889claireho /** 46927f654740f2a26ad62a5c155af9199af9e69b889claireho * A label contains a dot=full stop. 47027f654740f2a26ad62a5c155af9199af9e69b889claireho * This can occur in an input string for a single-label function. 471103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 47227f654740f2a26ad62a5c155af9199af9e69b889claireho */ 47327f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_ERROR_LABEL_HAS_DOT=0x200, 47427f654740f2a26ad62a5c155af9199af9e69b889claireho /** 47527f654740f2a26ad62a5c155af9199af9e69b889claireho * An ACE label does not contain a valid label string. 47627f654740f2a26ad62a5c155af9199af9e69b889claireho * The label was successfully ACE (Punycode) decoded but the resulting 47727f654740f2a26ad62a5c155af9199af9e69b889claireho * string had severe validation errors. For example, 47827f654740f2a26ad62a5c155af9199af9e69b889claireho * it might contain characters that are not allowed in ACE labels, 47927f654740f2a26ad62a5c155af9199af9e69b889claireho * or it might not be normalized. 480103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 48127f654740f2a26ad62a5c155af9199af9e69b889claireho */ 48227f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_ERROR_INVALID_ACE_LABEL=0x400, 48327f654740f2a26ad62a5c155af9199af9e69b889claireho /** 48427f654740f2a26ad62a5c155af9199af9e69b889claireho * A label does not meet the IDNA BiDi requirements (for right-to-left characters). 485103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 48627f654740f2a26ad62a5c155af9199af9e69b889claireho */ 48727f654740f2a26ad62a5c155af9199af9e69b889claireho UIDNA_ERROR_BIDI=0x800, 48827f654740f2a26ad62a5c155af9199af9e69b889claireho /** 48927f654740f2a26ad62a5c155af9199af9e69b889claireho * A label does not meet the IDNA CONTEXTJ requirements. 490103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6 491103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius */ 492103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius UIDNA_ERROR_CONTEXTJ=0x1000, 493103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#ifndef U_HIDE_DRAFT_API 494103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius /** 495103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * A label does not meet the IDNA CONTEXTO requirements for punctuation characters. 496103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * Some punctuation characters "Would otherwise have been DISALLOWED" 497103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * but are allowed in certain contexts. (RFC 5892) 498103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @draft ICU 49 499103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius */ 500103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius UIDNA_ERROR_CONTEXTO_PUNCTUATION=0x2000, 501103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius /** 502103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * A label does not meet the IDNA CONTEXTO requirements for digits. 503103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * Arabic-Indic Digits (U+066x) must not be mixed with Extended Arabic-Indic Digits (U+06Fx). 504103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @draft ICU 49 50527f654740f2a26ad62a5c155af9199af9e69b889claireho */ 506103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius UIDNA_ERROR_CONTEXTO_DIGITS=0x4000 507103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius#endif /* U_HIDE_DRAFT_API */ 50827f654740f2a26ad62a5c155af9199af9e69b889claireho}; 50927f654740f2a26ad62a5c155af9199af9e69b889claireho 51027f654740f2a26ad62a5c155af9199af9e69b889claireho/* IDNA2003 API ------------------------------------------------------------- */ 51127f654740f2a26ad62a5c155af9199af9e69b889claireho 51227f654740f2a26ad62a5c155af9199af9e69b889claireho/** 51327f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA2003: This function implements the ToASCII operation as defined in the IDNA RFC. 514b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This operation is done on <b>single labels</b> before sending it to something that expects 515b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * ASCII names. A label is an individual part of a domain name. Labels are usually 51650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * separated by dots; e.g. "www.example.com" is composed of 3 labels "www","example", and "com". 517b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 51827f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA2003 API Overview: 51927f654740f2a26ad62a5c155af9199af9e69b889claireho * 52027f654740f2a26ad62a5c155af9199af9e69b889claireho * The uidna_ API implements the IDNA protocol as defined in the IDNA RFC 52127f654740f2a26ad62a5c155af9199af9e69b889claireho * (http://www.ietf.org/rfc/rfc3490.txt). 52227f654740f2a26ad62a5c155af9199af9e69b889claireho * The RFC defines 2 operations: ToASCII and ToUnicode. Domain name labels 52327f654740f2a26ad62a5c155af9199af9e69b889claireho * containing non-ASCII code points are processed by the 52427f654740f2a26ad62a5c155af9199af9e69b889claireho * ToASCII operation before passing it to resolver libraries. Domain names 52527f654740f2a26ad62a5c155af9199af9e69b889claireho * that are obtained from resolver libraries are processed by the 52627f654740f2a26ad62a5c155af9199af9e69b889claireho * ToUnicode operation before displaying the domain name to the user. 52727f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA requires that implementations process input strings with Nameprep 52827f654740f2a26ad62a5c155af9199af9e69b889claireho * (http://www.ietf.org/rfc/rfc3491.txt), 52927f654740f2a26ad62a5c155af9199af9e69b889claireho * which is a profile of Stringprep (http://www.ietf.org/rfc/rfc3454.txt), 53027f654740f2a26ad62a5c155af9199af9e69b889claireho * and then with Punycode (http://www.ietf.org/rfc/rfc3492.txt). 53127f654740f2a26ad62a5c155af9199af9e69b889claireho * Implementations of IDNA MUST fully implement Nameprep and Punycode; 53227f654740f2a26ad62a5c155af9199af9e69b889claireho * neither Nameprep nor Punycode are optional. 53327f654740f2a26ad62a5c155af9199af9e69b889claireho * The input and output of ToASCII and ToUnicode operations are Unicode 53427f654740f2a26ad62a5c155af9199af9e69b889claireho * and are designed to be chainable, i.e., applying ToASCII or ToUnicode operations 53527f654740f2a26ad62a5c155af9199af9e69b889claireho * multiple times to an input string will yield the same result as applying the operation 53627f654740f2a26ad62a5c155af9199af9e69b889claireho * once. 53727f654740f2a26ad62a5c155af9199af9e69b889claireho * ToUnicode(ToUnicode(ToUnicode...(ToUnicode(string)))) == ToUnicode(string) 53827f654740f2a26ad62a5c155af9199af9e69b889claireho * ToASCII(ToASCII(ToASCII...(ToASCII(string))) == ToASCII(string). 539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param src Input UChar array containing label in Unicode. 541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength Number of UChars in src, or -1 if NUL-terminated. 542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dest Output UChar array with ASCII (ACE encoded) label. 543b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param destCapacity Size of dest. 544b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options A bit set of options: 545b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points 547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and do not use STD3 ASCII rules 548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If unassigned code points are found the operation fails with 549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_UNASSIGNED_ERROR error code. 550b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations 552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If this option is set, the unassigned code points are in the input 553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * are treated as normal Unicode code points. 55427f654740f2a26ad62a5c155af9199af9e69b889claireho * 555b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions 556b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If this option is set and the input does not satisfy STD3 rules, 557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR 558b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param parseError Pointer to UParseError struct to receive information on position 560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * of error if an error is encountered. Can be NULL. 561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status ICU in/out error code parameter. 562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_INVALID_CHAR_FOUND if src contains 563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * unmatched single surrogates. 564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_INDEX_OUTOFBOUNDS_ERROR if src contains 565b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * too many code points. 566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough 567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The length of the result string, if successful - or in case of a buffer overflow, 568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in which case it will be greater than destCapacity. 569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.6 570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int32_t U_EXPORT2 572b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruuidna_toASCII(const UChar* src, int32_t srcLength, 573b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar* dest, int32_t destCapacity, 574b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t options, 575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UParseError* parseError, 576b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode* status); 577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 579b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 58027f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA2003: This function implements the ToUnicode operation as defined in the IDNA RFC. 581b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This operation is done on <b>single labels</b> before sending it to something that expects 582b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Unicode names. A label is an individual part of a domain name. Labels are usually 58350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * separated by dots; for e.g. "www.example.com" is composed of 3 labels "www","example", and "com". 584b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 585b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param src Input UChar array containing ASCII (ACE encoded) label. 586b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength Number of UChars in src, or -1 if NUL-terminated. 587b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dest Output Converted UChar array containing Unicode equivalent of label. 588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param destCapacity Size of dest. 589b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options A bit set of options: 59027f654740f2a26ad62a5c155af9199af9e69b889claireho * 591b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points 592b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and do not use STD3 ASCII rules 593b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If unassigned code points are found the operation fails with 594b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_UNASSIGNED_ERROR error code. 595b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 596b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations 597b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If this option is set, the unassigned code points are in the input 598b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * are treated as normal Unicode code points. <b> Note: </b> This option is 599b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * required on toUnicode operation because the RFC mandates 600b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * verification of decoded ACE input by applying toASCII and comparing 601b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * its output with source 602b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 603b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions 604b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If this option is set and the input does not satisfy STD3 rules, 605b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR 606b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 607b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param parseError Pointer to UParseError struct to receive information on position 608b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * of error if an error is encountered. Can be NULL. 609b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status ICU in/out error code parameter. 610b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_INVALID_CHAR_FOUND if src contains 611b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * unmatched single surrogates. 612b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_INDEX_OUTOFBOUNDS_ERROR if src contains 613b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * too many code points. 614b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough 615b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The length of the result string, if successful - or in case of a buffer overflow, 616b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in which case it will be greater than destCapacity. 617b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.6 618b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 619b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int32_t U_EXPORT2 620b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruuidna_toUnicode(const UChar* src, int32_t srcLength, 621b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar* dest, int32_t destCapacity, 622b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t options, 623b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UParseError* parseError, 624b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode* status); 625b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 626b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 627b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 62827f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA2003: Convenience function that implements the IDNToASCII operation as defined in the IDNA RFC. 629b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This operation is done on complete domain names, e.g: "www.example.com". 630b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It is important to note that this operation can fail. If it fails, then the input 631b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * domain name cannot be used as an Internationalized Domain Name and the application 632b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * should have methods defined to deal with the failure. 63327f654740f2a26ad62a5c155af9199af9e69b889claireho * 634b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <b>Note:</b> IDNA RFC specifies that a conformant application should divide a domain name 635b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, 636b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and then convert. This function does not offer that level of granularity. The options once 637b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * set will apply to all labels in the domain name 638b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 639b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param src Input UChar array containing IDN in Unicode. 640b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength Number of UChars in src, or -1 if NUL-terminated. 641b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dest Output UChar array with ASCII (ACE encoded) IDN. 642b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param destCapacity Size of dest. 643b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options A bit set of options: 64427f654740f2a26ad62a5c155af9199af9e69b889claireho * 645b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points 646b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and do not use STD3 ASCII rules 647b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If unassigned code points are found the operation fails with 648b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_UNASSIGNED_CODE_POINT_FOUND error code. 649b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 650b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations 651b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If this option is set, the unassigned code points are in the input 652b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * are treated as normal Unicode code points. 65327f654740f2a26ad62a5c155af9199af9e69b889claireho * 654b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions 655b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If this option is set and the input does not satisfy STD3 rules, 656b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR 65727f654740f2a26ad62a5c155af9199af9e69b889claireho * 658b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param parseError Pointer to UParseError struct to receive information on position 659b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * of error if an error is encountered. Can be NULL. 660b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status ICU in/out error code parameter. 661b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_INVALID_CHAR_FOUND if src contains 662b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * unmatched single surrogates. 663b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_INDEX_OUTOFBOUNDS_ERROR if src contains 664b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * too many code points. 665b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough 666b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The length of the result string, if successful - or in case of a buffer overflow, 667b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in which case it will be greater than destCapacity. 668b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.6 669b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 670b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int32_t U_EXPORT2 671b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruuidna_IDNToASCII( const UChar* src, int32_t srcLength, 672b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar* dest, int32_t destCapacity, 673b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t options, 674b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UParseError* parseError, 675b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode* status); 676b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 677b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 67827f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA2003: Convenience function that implements the IDNToUnicode operation as defined in the IDNA RFC. 679b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This operation is done on complete domain names, e.g: "www.example.com". 680b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 681b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <b>Note:</b> IDNA RFC specifies that a conformant application should divide a domain name 682b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each, 683b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and then convert. This function does not offer that level of granularity. The options once 684b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * set will apply to all labels in the domain name 685b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 686b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param src Input UChar array containing IDN in ASCII (ACE encoded) form. 687b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength Number of UChars in src, or -1 if NUL-terminated. 688b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dest Output UChar array containing Unicode equivalent of source IDN. 689b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param destCapacity Size of dest. 690b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options A bit set of options: 69127f654740f2a26ad62a5c155af9199af9e69b889claireho * 692b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points 693b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and do not use STD3 ASCII rules 694b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If unassigned code points are found the operation fails with 695b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_UNASSIGNED_CODE_POINT_FOUND error code. 696b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 697b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations 698b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If this option is set, the unassigned code points are in the input 699b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * are treated as normal Unicode code points. 70027f654740f2a26ad62a5c155af9199af9e69b889claireho * 701b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions 702b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If this option is set and the input does not satisfy STD3 rules, 703b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR 704b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 705b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param parseError Pointer to UParseError struct to receive information on position 706b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * of error if an error is encountered. Can be NULL. 707b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status ICU in/out error code parameter. 708b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_INVALID_CHAR_FOUND if src contains 709b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * unmatched single surrogates. 710b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_INDEX_OUTOFBOUNDS_ERROR if src contains 711b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * too many code points. 712b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough 713b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The length of the result string, if successful - or in case of a buffer overflow, 714b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in which case it will be greater than destCapacity. 715b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.6 716b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 717b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int32_t U_EXPORT2 718b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruuidna_IDNToUnicode( const UChar* src, int32_t srcLength, 719b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar* dest, int32_t destCapacity, 720b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t options, 721b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UParseError* parseError, 722b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode* status); 723b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 724b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 72527f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA2003: Compare two IDN strings for equivalence. 726b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function splits the domain names into labels and compares them. 727b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * According to IDN RFC, whenever two labels are compared, they are 728b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * considered equal if and only if their ASCII forms (obtained by 729b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * applying toASCII) match using an case-insensitive ASCII comparison. 730b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Two domain names are considered a match if and only if all labels 731b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * match regardless of whether label separators match. 732b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 733b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param s1 First source string. 734b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length1 Length of first source string, or -1 if NUL-terminated. 735b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 736b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param s2 Second source string. 737b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length2 Length of second source string, or -1 if NUL-terminated. 738b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options A bit set of options: 73927f654740f2a26ad62a5c155af9199af9e69b889claireho * 740b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - UIDNA_DEFAULT Use default options, i.e., do not process unassigned code points 741b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and do not use STD3 ASCII rules 742b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If unassigned code points are found the operation fails with 743b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * U_UNASSIGNED_CODE_POINT_FOUND error code. 744b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 745b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - UIDNA_ALLOW_UNASSIGNED Unassigned values can be converted to ASCII for query operations 746b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If this option is set, the unassigned code points are in the input 747b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * are treated as normal Unicode code points. 74827f654740f2a26ad62a5c155af9199af9e69b889claireho * 749b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * - UIDNA_USE_STD3_RULES Use STD3 ASCII rules for host name syntax restrictions 750b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If this option is set and the input does not satisfy STD3 rules, 751b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR 752b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 753b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status ICU error code in/out parameter. 754b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Must fulfill U_SUCCESS before the function call. 755b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return <0 or 0 or >0 as usual for string comparisons 756b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.6 757b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 758b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int32_t U_EXPORT2 759b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruuidna_compare( const UChar *s1, int32_t length1, 760b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *s2, int32_t length2, 761b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t options, 762b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode* status); 763b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 764b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif /* #if !UCONFIG_NO_IDNA */ 765b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 766b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 767