1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*
2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *******************************************************************************
3b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
48393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius *   Copyright (C) 2003-2013, 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    /**
100103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * IDNA option to check for whether the input conforms to the CONTEXTO rules.
101103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * For use in static worker and factory methods.
102103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * <p>This option is ignored by the IDNA2003 implementation.
103103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * (The CONTEXTO check is new in IDNA2008.)
104103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * <p>This is for use by registries for IDNA2008 conformance.
105103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * UTS #46 does not require the CONTEXTO check.
1068393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius     * @stable ICU 49
107103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     */
108103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    UIDNA_CHECK_CONTEXTO=0x40
10927f654740f2a26ad62a5c155af9199af9e69b889claireho};
11027f654740f2a26ad62a5c155af9199af9e69b889claireho
11127f654740f2a26ad62a5c155af9199af9e69b889claireho/**
11227f654740f2a26ad62a5c155af9199af9e69b889claireho * Opaque C service object type for the new IDNA API.
113103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6
114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
11527f654740f2a26ad62a5c155af9199af9e69b889clairehostruct UIDNA;
116103e9ffba2cba345d0078eb8b8db33249f81840aCraig Corneliustypedef struct UIDNA UIDNA;  /**< C typedef for struct UIDNA. @stable ICU 4.6 */
11727f654740f2a26ad62a5c155af9199af9e69b889claireho
11827f654740f2a26ad62a5c155af9199af9e69b889claireho/**
11927f654740f2a26ad62a5c155af9199af9e69b889claireho * Returns a UIDNA instance which implements UTS #46.
12027f654740f2a26ad62a5c155af9199af9e69b889claireho * Returns an unmodifiable instance, owned by the caller.
12127f654740f2a26ad62a5c155af9199af9e69b889claireho * Cache it for multiple operations, and uidna_close() it when done.
12227f654740f2a26ad62a5c155af9199af9e69b889claireho * The instance is thread-safe, that is, it can be used concurrently.
12327f654740f2a26ad62a5c155af9199af9e69b889claireho *
12427f654740f2a26ad62a5c155af9199af9e69b889claireho * For details about the UTS #46 implementation see the IDNA C++ class in idna.h.
12527f654740f2a26ad62a5c155af9199af9e69b889claireho *
12627f654740f2a26ad62a5c155af9199af9e69b889claireho * @param options Bit set to modify the processing and error checking.
12727f654740f2a26ad62a5c155af9199af9e69b889claireho *                See option bit set values in uidna.h.
12827f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must
12927f654740f2a26ad62a5c155af9199af9e69b889claireho *                  pass the U_SUCCESS() test, or else the function returns
13027f654740f2a26ad62a5c155af9199af9e69b889claireho *                  immediately. Check for U_FAILURE() on output or use with
13127f654740f2a26ad62a5c155af9199af9e69b889claireho *                  function chaining. (See User Guide for details.)
13227f654740f2a26ad62a5c155af9199af9e69b889claireho * @return the UTS #46 UIDNA instance, if successful
133103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6
13427f654740f2a26ad62a5c155af9199af9e69b889claireho */
13554dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE UIDNA * U_EXPORT2
13627f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_openUTS46(uint32_t options, UErrorCode *pErrorCode);
13727f654740f2a26ad62a5c155af9199af9e69b889claireho
13827f654740f2a26ad62a5c155af9199af9e69b889claireho/**
13927f654740f2a26ad62a5c155af9199af9e69b889claireho * Closes a UIDNA instance.
14027f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance to be closed
141103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6
142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
14354dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE void U_EXPORT2
14427f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_close(UIDNA *idna);
14527f654740f2a26ad62a5c155af9199af9e69b889claireho
14627f654740f2a26ad62a5c155af9199af9e69b889claireho#if U_SHOW_CPLUSPLUS_API
14727f654740f2a26ad62a5c155af9199af9e69b889claireho
14827f654740f2a26ad62a5c155af9199af9e69b889clairehoU_NAMESPACE_BEGIN
149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
15127f654740f2a26ad62a5c155af9199af9e69b889claireho * \class LocalUIDNAPointer
15227f654740f2a26ad62a5c155af9199af9e69b889claireho * "Smart pointer" class, closes a UIDNA via uidna_close().
15327f654740f2a26ad62a5c155af9199af9e69b889claireho * For most methods see the LocalPointerBase base class.
15427f654740f2a26ad62a5c155af9199af9e69b889claireho *
15527f654740f2a26ad62a5c155af9199af9e69b889claireho * @see LocalPointerBase
15627f654740f2a26ad62a5c155af9199af9e69b889claireho * @see LocalPointer
157103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6
15827f654740f2a26ad62a5c155af9199af9e69b889claireho */
15927f654740f2a26ad62a5c155af9199af9e69b889clairehoU_DEFINE_LOCAL_OPEN_POINTER(LocalUIDNAPointer, UIDNA, uidna_close);
16027f654740f2a26ad62a5c155af9199af9e69b889claireho
16127f654740f2a26ad62a5c155af9199af9e69b889clairehoU_NAMESPACE_END
16227f654740f2a26ad62a5c155af9199af9e69b889claireho
16327f654740f2a26ad62a5c155af9199af9e69b889claireho#endif
16427f654740f2a26ad62a5c155af9199af9e69b889claireho
16527f654740f2a26ad62a5c155af9199af9e69b889claireho/**
16627f654740f2a26ad62a5c155af9199af9e69b889claireho * Output container for IDNA processing errors.
16727f654740f2a26ad62a5c155af9199af9e69b889claireho * Initialize with UIDNA_INFO_INITIALIZER:
16827f654740f2a26ad62a5c155af9199af9e69b889claireho * \code
16927f654740f2a26ad62a5c155af9199af9e69b889claireho * UIDNAInfo info = UIDNA_INFO_INITIALIZER;
17027f654740f2a26ad62a5c155af9199af9e69b889claireho * int32_t length = uidna_nameToASCII(..., &info, &errorCode);
17127f654740f2a26ad62a5c155af9199af9e69b889claireho * if(U_SUCCESS(errorCode) && info.errors!=0) { ... }
17227f654740f2a26ad62a5c155af9199af9e69b889claireho * \endcode
173103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6
17427f654740f2a26ad62a5c155af9199af9e69b889claireho */
17554dcd9b6a06071f647dac967e9e267abb9410720Craig Corneliustypedef struct UIDNAInfo {
176103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    /** sizeof(UIDNAInfo) @stable ICU 4.6 */
17727f654740f2a26ad62a5c155af9199af9e69b889claireho    int16_t size;
17827f654740f2a26ad62a5c155af9199af9e69b889claireho    /**
17927f654740f2a26ad62a5c155af9199af9e69b889claireho     * Set to TRUE if transitional and nontransitional processing produce different results.
18027f654740f2a26ad62a5c155af9199af9e69b889claireho     * For details see C++ IDNAInfo::isTransitionalDifferent().
181103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.6
18227f654740f2a26ad62a5c155af9199af9e69b889claireho     */
18327f654740f2a26ad62a5c155af9199af9e69b889claireho    UBool isTransitionalDifferent;
18427f654740f2a26ad62a5c155af9199af9e69b889claireho    UBool reservedB3;  /**< Reserved field, do not use. @internal */
18527f654740f2a26ad62a5c155af9199af9e69b889claireho    /**
18627f654740f2a26ad62a5c155af9199af9e69b889claireho     * Bit set indicating IDNA processing errors. 0 if no errors.
18727f654740f2a26ad62a5c155af9199af9e69b889claireho     * See UIDNA_ERROR_... constants.
188103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.6
18927f654740f2a26ad62a5c155af9199af9e69b889claireho     */
19027f654740f2a26ad62a5c155af9199af9e69b889claireho    uint32_t errors;
19127f654740f2a26ad62a5c155af9199af9e69b889claireho    int32_t reservedI2;  /**< Reserved field, do not use. @internal */
19227f654740f2a26ad62a5c155af9199af9e69b889claireho    int32_t reservedI3;  /**< Reserved field, do not use. @internal */
19354dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius} UIDNAInfo;
19427f654740f2a26ad62a5c155af9199af9e69b889claireho
19527f654740f2a26ad62a5c155af9199af9e69b889claireho/**
19627f654740f2a26ad62a5c155af9199af9e69b889claireho * Static initializer for a UIDNAInfo struct.
197103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6
19827f654740f2a26ad62a5c155af9199af9e69b889claireho */
19927f654740f2a26ad62a5c155af9199af9e69b889claireho#define UIDNA_INFO_INITIALIZER { \
20027f654740f2a26ad62a5c155af9199af9e69b889claireho    (int16_t)sizeof(UIDNAInfo), \
20127f654740f2a26ad62a5c155af9199af9e69b889claireho    FALSE, FALSE, \
20227f654740f2a26ad62a5c155af9199af9e69b889claireho    0, 0, 0 }
20327f654740f2a26ad62a5c155af9199af9e69b889claireho
20427f654740f2a26ad62a5c155af9199af9e69b889claireho/**
20527f654740f2a26ad62a5c155af9199af9e69b889claireho * Converts a single domain name label into its ASCII form for DNS lookup.
20627f654740f2a26ad62a5c155af9199af9e69b889claireho * If any processing step fails, then pInfo->errors will be non-zero and
20727f654740f2a26ad62a5c155af9199af9e69b889claireho * the result might not be an ASCII string.
20827f654740f2a26ad62a5c155af9199af9e69b889claireho * The label might be modified according to the types of errors.
20927f654740f2a26ad62a5c155af9199af9e69b889claireho * Labels with severe errors will be left in (or turned into) their Unicode form.
21027f654740f2a26ad62a5c155af9199af9e69b889claireho *
21127f654740f2a26ad62a5c155af9199af9e69b889claireho * The UErrorCode indicates an error only in exceptional cases,
21227f654740f2a26ad62a5c155af9199af9e69b889claireho * such as a U_MEMORY_ALLOCATION_ERROR.
21327f654740f2a26ad62a5c155af9199af9e69b889claireho *
21427f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance
21527f654740f2a26ad62a5c155af9199af9e69b889claireho * @param label Input domain name label
21627f654740f2a26ad62a5c155af9199af9e69b889claireho * @param length Label length, or -1 if NUL-terminated
21727f654740f2a26ad62a5c155af9199af9e69b889claireho * @param dest Destination string buffer
21827f654740f2a26ad62a5c155af9199af9e69b889claireho * @param capacity Destination buffer capacity
21927f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pInfo Output container of IDNA processing details.
22027f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must
22127f654740f2a26ad62a5c155af9199af9e69b889claireho *                  pass the U_SUCCESS() test, or else the function returns
22227f654740f2a26ad62a5c155af9199af9e69b889claireho *                  immediately. Check for U_FAILURE() on output or use with
22327f654740f2a26ad62a5c155af9199af9e69b889claireho *                  function chaining. (See User Guide for details.)
22427f654740f2a26ad62a5c155af9199af9e69b889claireho * @return destination string length
225103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6
22627f654740f2a26ad62a5c155af9199af9e69b889claireho */
22754dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE int32_t U_EXPORT2
22827f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_labelToASCII(const UIDNA *idna,
22927f654740f2a26ad62a5c155af9199af9e69b889claireho                   const UChar *label, int32_t length,
23027f654740f2a26ad62a5c155af9199af9e69b889claireho                   UChar *dest, int32_t capacity,
23127f654740f2a26ad62a5c155af9199af9e69b889claireho                   UIDNAInfo *pInfo, UErrorCode *pErrorCode);
23227f654740f2a26ad62a5c155af9199af9e69b889claireho
23327f654740f2a26ad62a5c155af9199af9e69b889claireho/**
23427f654740f2a26ad62a5c155af9199af9e69b889claireho * Converts a single domain name label into its Unicode form for human-readable display.
23527f654740f2a26ad62a5c155af9199af9e69b889claireho * If any processing step fails, then pInfo->errors will be non-zero.
23627f654740f2a26ad62a5c155af9199af9e69b889claireho * The label might be modified according to the types of errors.
23727f654740f2a26ad62a5c155af9199af9e69b889claireho *
23827f654740f2a26ad62a5c155af9199af9e69b889claireho * The UErrorCode indicates an error only in exceptional cases,
23927f654740f2a26ad62a5c155af9199af9e69b889claireho * such as a U_MEMORY_ALLOCATION_ERROR.
24027f654740f2a26ad62a5c155af9199af9e69b889claireho *
24127f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance
24227f654740f2a26ad62a5c155af9199af9e69b889claireho * @param label Input domain name label
24327f654740f2a26ad62a5c155af9199af9e69b889claireho * @param length Label length, or -1 if NUL-terminated
24427f654740f2a26ad62a5c155af9199af9e69b889claireho * @param dest Destination string buffer
24527f654740f2a26ad62a5c155af9199af9e69b889claireho * @param capacity Destination buffer capacity
24627f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pInfo Output container of IDNA processing details.
24727f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must
24827f654740f2a26ad62a5c155af9199af9e69b889claireho *                  pass the U_SUCCESS() test, or else the function returns
24927f654740f2a26ad62a5c155af9199af9e69b889claireho *                  immediately. Check for U_FAILURE() on output or use with
25027f654740f2a26ad62a5c155af9199af9e69b889claireho *                  function chaining. (See User Guide for details.)
25127f654740f2a26ad62a5c155af9199af9e69b889claireho * @return destination string length
252103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6
25327f654740f2a26ad62a5c155af9199af9e69b889claireho */
25454dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE int32_t U_EXPORT2
25527f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_labelToUnicode(const UIDNA *idna,
25627f654740f2a26ad62a5c155af9199af9e69b889claireho                     const UChar *label, int32_t length,
25727f654740f2a26ad62a5c155af9199af9e69b889claireho                     UChar *dest, int32_t capacity,
25827f654740f2a26ad62a5c155af9199af9e69b889claireho                     UIDNAInfo *pInfo, UErrorCode *pErrorCode);
25927f654740f2a26ad62a5c155af9199af9e69b889claireho
26027f654740f2a26ad62a5c155af9199af9e69b889claireho/**
26127f654740f2a26ad62a5c155af9199af9e69b889claireho * Converts a whole domain name into its ASCII form for DNS lookup.
26227f654740f2a26ad62a5c155af9199af9e69b889claireho * If any processing step fails, then pInfo->errors will be non-zero and
26327f654740f2a26ad62a5c155af9199af9e69b889claireho * the result might not be an ASCII string.
26427f654740f2a26ad62a5c155af9199af9e69b889claireho * The domain name might be modified according to the types of errors.
26527f654740f2a26ad62a5c155af9199af9e69b889claireho * Labels with severe errors will be left in (or turned into) their Unicode form.
26627f654740f2a26ad62a5c155af9199af9e69b889claireho *
26727f654740f2a26ad62a5c155af9199af9e69b889claireho * The UErrorCode indicates an error only in exceptional cases,
26827f654740f2a26ad62a5c155af9199af9e69b889claireho * such as a U_MEMORY_ALLOCATION_ERROR.
26927f654740f2a26ad62a5c155af9199af9e69b889claireho *
27027f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance
27127f654740f2a26ad62a5c155af9199af9e69b889claireho * @param name Input domain name
27227f654740f2a26ad62a5c155af9199af9e69b889claireho * @param length Domain name length, or -1 if NUL-terminated
27327f654740f2a26ad62a5c155af9199af9e69b889claireho * @param dest Destination string buffer
27427f654740f2a26ad62a5c155af9199af9e69b889claireho * @param capacity Destination buffer capacity
27527f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pInfo Output container of IDNA processing details.
27627f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must
27727f654740f2a26ad62a5c155af9199af9e69b889claireho *                  pass the U_SUCCESS() test, or else the function returns
27827f654740f2a26ad62a5c155af9199af9e69b889claireho *                  immediately. Check for U_FAILURE() on output or use with
27927f654740f2a26ad62a5c155af9199af9e69b889claireho *                  function chaining. (See User Guide for details.)
28027f654740f2a26ad62a5c155af9199af9e69b889claireho * @return destination string length
281103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6
28227f654740f2a26ad62a5c155af9199af9e69b889claireho */
28354dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE int32_t U_EXPORT2
28427f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_nameToASCII(const UIDNA *idna,
28527f654740f2a26ad62a5c155af9199af9e69b889claireho                  const UChar *name, int32_t length,
28627f654740f2a26ad62a5c155af9199af9e69b889claireho                  UChar *dest, int32_t capacity,
28727f654740f2a26ad62a5c155af9199af9e69b889claireho                  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
28827f654740f2a26ad62a5c155af9199af9e69b889claireho
28927f654740f2a26ad62a5c155af9199af9e69b889claireho/**
29027f654740f2a26ad62a5c155af9199af9e69b889claireho * Converts a whole domain name into its Unicode form for human-readable display.
29127f654740f2a26ad62a5c155af9199af9e69b889claireho * If any processing step fails, then pInfo->errors will be non-zero.
29227f654740f2a26ad62a5c155af9199af9e69b889claireho * The domain name might be modified according to the types of errors.
29327f654740f2a26ad62a5c155af9199af9e69b889claireho *
29427f654740f2a26ad62a5c155af9199af9e69b889claireho * The UErrorCode indicates an error only in exceptional cases,
29527f654740f2a26ad62a5c155af9199af9e69b889claireho * such as a U_MEMORY_ALLOCATION_ERROR.
29627f654740f2a26ad62a5c155af9199af9e69b889claireho *
29727f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance
29827f654740f2a26ad62a5c155af9199af9e69b889claireho * @param name Input domain name
29927f654740f2a26ad62a5c155af9199af9e69b889claireho * @param length Domain name length, or -1 if NUL-terminated
30027f654740f2a26ad62a5c155af9199af9e69b889claireho * @param dest Destination string buffer
30127f654740f2a26ad62a5c155af9199af9e69b889claireho * @param capacity Destination buffer capacity
30227f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pInfo Output container of IDNA processing details.
30327f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must
30427f654740f2a26ad62a5c155af9199af9e69b889claireho *                  pass the U_SUCCESS() test, or else the function returns
30527f654740f2a26ad62a5c155af9199af9e69b889claireho *                  immediately. Check for U_FAILURE() on output or use with
30627f654740f2a26ad62a5c155af9199af9e69b889claireho *                  function chaining. (See User Guide for details.)
30727f654740f2a26ad62a5c155af9199af9e69b889claireho * @return destination string length
308103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6
30927f654740f2a26ad62a5c155af9199af9e69b889claireho */
31054dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE int32_t U_EXPORT2
31127f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_nameToUnicode(const UIDNA *idna,
31227f654740f2a26ad62a5c155af9199af9e69b889claireho                    const UChar *name, int32_t length,
31327f654740f2a26ad62a5c155af9199af9e69b889claireho                    UChar *dest, int32_t capacity,
31427f654740f2a26ad62a5c155af9199af9e69b889claireho                    UIDNAInfo *pInfo, UErrorCode *pErrorCode);
31527f654740f2a26ad62a5c155af9199af9e69b889claireho
31627f654740f2a26ad62a5c155af9199af9e69b889claireho/* UTF-8 versions of the processing methods --------------------------------- */
31727f654740f2a26ad62a5c155af9199af9e69b889claireho
31827f654740f2a26ad62a5c155af9199af9e69b889claireho/**
31927f654740f2a26ad62a5c155af9199af9e69b889claireho * Converts a single domain name label into its ASCII form for DNS lookup.
32027f654740f2a26ad62a5c155af9199af9e69b889claireho * UTF-8 version of uidna_labelToASCII(), same behavior.
32127f654740f2a26ad62a5c155af9199af9e69b889claireho *
32227f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance
32327f654740f2a26ad62a5c155af9199af9e69b889claireho * @param label Input domain name label
32427f654740f2a26ad62a5c155af9199af9e69b889claireho * @param length Label length, or -1 if NUL-terminated
32527f654740f2a26ad62a5c155af9199af9e69b889claireho * @param dest Destination string buffer
32627f654740f2a26ad62a5c155af9199af9e69b889claireho * @param capacity Destination buffer capacity
32727f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pInfo Output container of IDNA processing details.
32827f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must
32927f654740f2a26ad62a5c155af9199af9e69b889claireho *                  pass the U_SUCCESS() test, or else the function returns
33027f654740f2a26ad62a5c155af9199af9e69b889claireho *                  immediately. Check for U_FAILURE() on output or use with
33127f654740f2a26ad62a5c155af9199af9e69b889claireho *                  function chaining. (See User Guide for details.)
33227f654740f2a26ad62a5c155af9199af9e69b889claireho * @return destination string length
333103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6
33427f654740f2a26ad62a5c155af9199af9e69b889claireho */
33554dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE int32_t U_EXPORT2
33627f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_labelToASCII_UTF8(const UIDNA *idna,
33727f654740f2a26ad62a5c155af9199af9e69b889claireho                        const char *label, int32_t length,
33827f654740f2a26ad62a5c155af9199af9e69b889claireho                        char *dest, int32_t capacity,
33927f654740f2a26ad62a5c155af9199af9e69b889claireho                        UIDNAInfo *pInfo, UErrorCode *pErrorCode);
34027f654740f2a26ad62a5c155af9199af9e69b889claireho
34127f654740f2a26ad62a5c155af9199af9e69b889claireho/**
34227f654740f2a26ad62a5c155af9199af9e69b889claireho * Converts a single domain name label into its Unicode form for human-readable display.
34327f654740f2a26ad62a5c155af9199af9e69b889claireho * UTF-8 version of uidna_labelToUnicode(), same behavior.
34427f654740f2a26ad62a5c155af9199af9e69b889claireho *
34527f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance
34627f654740f2a26ad62a5c155af9199af9e69b889claireho * @param label Input domain name label
34727f654740f2a26ad62a5c155af9199af9e69b889claireho * @param length Label length, or -1 if NUL-terminated
34827f654740f2a26ad62a5c155af9199af9e69b889claireho * @param dest Destination string buffer
34927f654740f2a26ad62a5c155af9199af9e69b889claireho * @param capacity Destination buffer capacity
35027f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pInfo Output container of IDNA processing details.
35127f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must
35227f654740f2a26ad62a5c155af9199af9e69b889claireho *                  pass the U_SUCCESS() test, or else the function returns
35327f654740f2a26ad62a5c155af9199af9e69b889claireho *                  immediately. Check for U_FAILURE() on output or use with
35427f654740f2a26ad62a5c155af9199af9e69b889claireho *                  function chaining. (See User Guide for details.)
35527f654740f2a26ad62a5c155af9199af9e69b889claireho * @return destination string length
356103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6
35727f654740f2a26ad62a5c155af9199af9e69b889claireho */
35854dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE int32_t U_EXPORT2
35927f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_labelToUnicodeUTF8(const UIDNA *idna,
36027f654740f2a26ad62a5c155af9199af9e69b889claireho                         const char *label, int32_t length,
36127f654740f2a26ad62a5c155af9199af9e69b889claireho                         char *dest, int32_t capacity,
36227f654740f2a26ad62a5c155af9199af9e69b889claireho                         UIDNAInfo *pInfo, UErrorCode *pErrorCode);
36327f654740f2a26ad62a5c155af9199af9e69b889claireho
36427f654740f2a26ad62a5c155af9199af9e69b889claireho/**
36527f654740f2a26ad62a5c155af9199af9e69b889claireho * Converts a whole domain name into its ASCII form for DNS lookup.
36627f654740f2a26ad62a5c155af9199af9e69b889claireho * UTF-8 version of uidna_nameToASCII(), same behavior.
36727f654740f2a26ad62a5c155af9199af9e69b889claireho *
36827f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance
36927f654740f2a26ad62a5c155af9199af9e69b889claireho * @param name Input domain name
37027f654740f2a26ad62a5c155af9199af9e69b889claireho * @param length Domain name length, or -1 if NUL-terminated
37127f654740f2a26ad62a5c155af9199af9e69b889claireho * @param dest Destination string buffer
37227f654740f2a26ad62a5c155af9199af9e69b889claireho * @param capacity Destination buffer capacity
37327f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pInfo Output container of IDNA processing details.
37427f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must
37527f654740f2a26ad62a5c155af9199af9e69b889claireho *                  pass the U_SUCCESS() test, or else the function returns
37627f654740f2a26ad62a5c155af9199af9e69b889claireho *                  immediately. Check for U_FAILURE() on output or use with
37727f654740f2a26ad62a5c155af9199af9e69b889claireho *                  function chaining. (See User Guide for details.)
37827f654740f2a26ad62a5c155af9199af9e69b889claireho * @return destination string length
379103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6
38027f654740f2a26ad62a5c155af9199af9e69b889claireho */
38154dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE int32_t U_EXPORT2
38227f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_nameToASCII_UTF8(const UIDNA *idna,
38327f654740f2a26ad62a5c155af9199af9e69b889claireho                       const char *name, int32_t length,
38427f654740f2a26ad62a5c155af9199af9e69b889claireho                       char *dest, int32_t capacity,
38527f654740f2a26ad62a5c155af9199af9e69b889claireho                       UIDNAInfo *pInfo, UErrorCode *pErrorCode);
38627f654740f2a26ad62a5c155af9199af9e69b889claireho
38727f654740f2a26ad62a5c155af9199af9e69b889claireho/**
38827f654740f2a26ad62a5c155af9199af9e69b889claireho * Converts a whole domain name into its Unicode form for human-readable display.
38927f654740f2a26ad62a5c155af9199af9e69b889claireho * UTF-8 version of uidna_nameToUnicode(), same behavior.
39027f654740f2a26ad62a5c155af9199af9e69b889claireho *
39127f654740f2a26ad62a5c155af9199af9e69b889claireho * @param idna UIDNA instance
39227f654740f2a26ad62a5c155af9199af9e69b889claireho * @param name Input domain name
39327f654740f2a26ad62a5c155af9199af9e69b889claireho * @param length Domain name length, or -1 if NUL-terminated
39427f654740f2a26ad62a5c155af9199af9e69b889claireho * @param dest Destination string buffer
39527f654740f2a26ad62a5c155af9199af9e69b889claireho * @param capacity Destination buffer capacity
39627f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pInfo Output container of IDNA processing details.
39727f654740f2a26ad62a5c155af9199af9e69b889claireho * @param pErrorCode Standard ICU error code. Its input value must
39827f654740f2a26ad62a5c155af9199af9e69b889claireho *                  pass the U_SUCCESS() test, or else the function returns
39927f654740f2a26ad62a5c155af9199af9e69b889claireho *                  immediately. Check for U_FAILURE() on output or use with
40027f654740f2a26ad62a5c155af9199af9e69b889claireho *                  function chaining. (See User Guide for details.)
40127f654740f2a26ad62a5c155af9199af9e69b889claireho * @return destination string length
402103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius * @stable ICU 4.6
40327f654740f2a26ad62a5c155af9199af9e69b889claireho */
40454dcd9b6a06071f647dac967e9e267abb9410720Craig CorneliusU_STABLE int32_t U_EXPORT2
40527f654740f2a26ad62a5c155af9199af9e69b889clairehouidna_nameToUnicodeUTF8(const UIDNA *idna,
40627f654740f2a26ad62a5c155af9199af9e69b889claireho                        const char *name, int32_t length,
40727f654740f2a26ad62a5c155af9199af9e69b889claireho                        char *dest, int32_t capacity,
40827f654740f2a26ad62a5c155af9199af9e69b889claireho                        UIDNAInfo *pInfo, UErrorCode *pErrorCode);
40927f654740f2a26ad62a5c155af9199af9e69b889claireho
41027f654740f2a26ad62a5c155af9199af9e69b889claireho/*
41127f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA error bit set values.
41227f654740f2a26ad62a5c155af9199af9e69b889claireho * When a domain name or label fails a processing step or does not meet the
41327f654740f2a26ad62a5c155af9199af9e69b889claireho * validity criteria, then one or more of these error bits are set.
41427f654740f2a26ad62a5c155af9199af9e69b889claireho */
41527f654740f2a26ad62a5c155af9199af9e69b889clairehoenum {
41627f654740f2a26ad62a5c155af9199af9e69b889claireho    /**
41727f654740f2a26ad62a5c155af9199af9e69b889claireho     * A non-final domain name label (or the whole domain name) is empty.
418103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.6
41927f654740f2a26ad62a5c155af9199af9e69b889claireho     */
42027f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_EMPTY_LABEL=1,
42127f654740f2a26ad62a5c155af9199af9e69b889claireho    /**
42227f654740f2a26ad62a5c155af9199af9e69b889claireho     * A domain name label is longer than 63 bytes.
42327f654740f2a26ad62a5c155af9199af9e69b889claireho     * (See STD13/RFC1034 3.1. Name space specifications and terminology.)
42427f654740f2a26ad62a5c155af9199af9e69b889claireho     * This is only checked in ToASCII operations, and only if the output label is all-ASCII.
425103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.6
42627f654740f2a26ad62a5c155af9199af9e69b889claireho     */
42727f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_LABEL_TOO_LONG=2,
42827f654740f2a26ad62a5c155af9199af9e69b889claireho    /**
42927f654740f2a26ad62a5c155af9199af9e69b889claireho     * A domain name is longer than 255 bytes in its storage form.
43027f654740f2a26ad62a5c155af9199af9e69b889claireho     * (See STD13/RFC1034 3.1. Name space specifications and terminology.)
43127f654740f2a26ad62a5c155af9199af9e69b889claireho     * This is only checked in ToASCII operations, and only if the output domain name is all-ASCII.
432103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.6
43327f654740f2a26ad62a5c155af9199af9e69b889claireho     */
43427f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_DOMAIN_NAME_TOO_LONG=4,
43527f654740f2a26ad62a5c155af9199af9e69b889claireho    /**
43627f654740f2a26ad62a5c155af9199af9e69b889claireho     * A label starts with a hyphen-minus ('-').
437103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.6
43827f654740f2a26ad62a5c155af9199af9e69b889claireho     */
43927f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_LEADING_HYPHEN=8,
44027f654740f2a26ad62a5c155af9199af9e69b889claireho    /**
44127f654740f2a26ad62a5c155af9199af9e69b889claireho     * A label ends with a hyphen-minus ('-').
442103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.6
44327f654740f2a26ad62a5c155af9199af9e69b889claireho     */
44427f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_TRAILING_HYPHEN=0x10,
44527f654740f2a26ad62a5c155af9199af9e69b889claireho    /**
44627f654740f2a26ad62a5c155af9199af9e69b889claireho     * A label contains hyphen-minus ('-') in the third and fourth positions.
447103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.6
44827f654740f2a26ad62a5c155af9199af9e69b889claireho     */
44927f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_HYPHEN_3_4=0x20,
45027f654740f2a26ad62a5c155af9199af9e69b889claireho    /**
45127f654740f2a26ad62a5c155af9199af9e69b889claireho     * A label starts with a combining mark.
452103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.6
45327f654740f2a26ad62a5c155af9199af9e69b889claireho     */
45427f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_LEADING_COMBINING_MARK=0x40,
45527f654740f2a26ad62a5c155af9199af9e69b889claireho    /**
45627f654740f2a26ad62a5c155af9199af9e69b889claireho     * A label or domain name contains disallowed characters.
457103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.6
45827f654740f2a26ad62a5c155af9199af9e69b889claireho     */
45927f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_DISALLOWED=0x80,
46027f654740f2a26ad62a5c155af9199af9e69b889claireho    /**
46127f654740f2a26ad62a5c155af9199af9e69b889claireho     * A label starts with "xn--" but does not contain valid Punycode.
46227f654740f2a26ad62a5c155af9199af9e69b889claireho     * That is, an xn-- label failed Punycode decoding.
463103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.6
46427f654740f2a26ad62a5c155af9199af9e69b889claireho     */
46527f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_PUNYCODE=0x100,
46627f654740f2a26ad62a5c155af9199af9e69b889claireho    /**
46727f654740f2a26ad62a5c155af9199af9e69b889claireho     * A label contains a dot=full stop.
46827f654740f2a26ad62a5c155af9199af9e69b889claireho     * This can occur in an input string for a single-label function.
469103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.6
47027f654740f2a26ad62a5c155af9199af9e69b889claireho     */
47127f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_LABEL_HAS_DOT=0x200,
47227f654740f2a26ad62a5c155af9199af9e69b889claireho    /**
47327f654740f2a26ad62a5c155af9199af9e69b889claireho     * An ACE label does not contain a valid label string.
47427f654740f2a26ad62a5c155af9199af9e69b889claireho     * The label was successfully ACE (Punycode) decoded but the resulting
47527f654740f2a26ad62a5c155af9199af9e69b889claireho     * string had severe validation errors. For example,
47627f654740f2a26ad62a5c155af9199af9e69b889claireho     * it might contain characters that are not allowed in ACE labels,
47727f654740f2a26ad62a5c155af9199af9e69b889claireho     * or it might not be normalized.
478103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.6
47927f654740f2a26ad62a5c155af9199af9e69b889claireho     */
48027f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_INVALID_ACE_LABEL=0x400,
48127f654740f2a26ad62a5c155af9199af9e69b889claireho    /**
48227f654740f2a26ad62a5c155af9199af9e69b889claireho     * A label does not meet the IDNA BiDi requirements (for right-to-left characters).
483103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.6
48427f654740f2a26ad62a5c155af9199af9e69b889claireho     */
48527f654740f2a26ad62a5c155af9199af9e69b889claireho    UIDNA_ERROR_BIDI=0x800,
48627f654740f2a26ad62a5c155af9199af9e69b889claireho    /**
48727f654740f2a26ad62a5c155af9199af9e69b889claireho     * A label does not meet the IDNA CONTEXTJ requirements.
488103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * @stable ICU 4.6
489103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     */
490103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    UIDNA_ERROR_CONTEXTJ=0x1000,
491103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    /**
492103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * A label does not meet the IDNA CONTEXTO requirements for punctuation characters.
493103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * Some punctuation characters "Would otherwise have been DISALLOWED"
494103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * but are allowed in certain contexts. (RFC 5892)
4958393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius     * @stable ICU 49
496103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     */
497103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    UIDNA_ERROR_CONTEXTO_PUNCTUATION=0x2000,
498103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    /**
499103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * A label does not meet the IDNA CONTEXTO requirements for digits.
500103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius     * Arabic-Indic Digits (U+066x) must not be mixed with Extended Arabic-Indic Digits (U+06Fx).
5018393335b955da7340c9f19b1b4b2d6c0c2c04be7Craig Cornelius     * @stable ICU 49
50227f654740f2a26ad62a5c155af9199af9e69b889claireho     */
503103e9ffba2cba345d0078eb8b8db33249f81840aCraig Cornelius    UIDNA_ERROR_CONTEXTO_DIGITS=0x4000
50427f654740f2a26ad62a5c155af9199af9e69b889claireho};
50527f654740f2a26ad62a5c155af9199af9e69b889claireho
50627f654740f2a26ad62a5c155af9199af9e69b889claireho/* IDNA2003 API ------------------------------------------------------------- */
50727f654740f2a26ad62a5c155af9199af9e69b889claireho
50827f654740f2a26ad62a5c155af9199af9e69b889claireho/**
50927f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA2003: This function implements the ToASCII operation as defined in the IDNA RFC.
510b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This operation is done on <b>single labels</b> before sending it to something that expects
511b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * ASCII names. A label is an individual part of a domain name. Labels are usually
51250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * separated by dots; e.g. "www.example.com" is composed of 3 labels "www","example", and "com".
513b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
51427f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA2003 API Overview:
51527f654740f2a26ad62a5c155af9199af9e69b889claireho *
51627f654740f2a26ad62a5c155af9199af9e69b889claireho * The uidna_ API implements the IDNA protocol as defined in the IDNA RFC
51727f654740f2a26ad62a5c155af9199af9e69b889claireho * (http://www.ietf.org/rfc/rfc3490.txt).
51827f654740f2a26ad62a5c155af9199af9e69b889claireho * The RFC defines 2 operations: ToASCII and ToUnicode. Domain name labels
51927f654740f2a26ad62a5c155af9199af9e69b889claireho * containing non-ASCII code points are processed by the
52027f654740f2a26ad62a5c155af9199af9e69b889claireho * ToASCII operation before passing it to resolver libraries. Domain names
52127f654740f2a26ad62a5c155af9199af9e69b889claireho * that are obtained from resolver libraries are processed by the
52227f654740f2a26ad62a5c155af9199af9e69b889claireho * ToUnicode operation before displaying the domain name to the user.
52327f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA requires that implementations process input strings with Nameprep
52427f654740f2a26ad62a5c155af9199af9e69b889claireho * (http://www.ietf.org/rfc/rfc3491.txt),
52527f654740f2a26ad62a5c155af9199af9e69b889claireho * which is a profile of Stringprep (http://www.ietf.org/rfc/rfc3454.txt),
52627f654740f2a26ad62a5c155af9199af9e69b889claireho * and then with Punycode (http://www.ietf.org/rfc/rfc3492.txt).
52727f654740f2a26ad62a5c155af9199af9e69b889claireho * Implementations of IDNA MUST fully implement Nameprep and Punycode;
52827f654740f2a26ad62a5c155af9199af9e69b889claireho * neither Nameprep nor Punycode are optional.
52927f654740f2a26ad62a5c155af9199af9e69b889claireho * The input and output of ToASCII and ToUnicode operations are Unicode
53027f654740f2a26ad62a5c155af9199af9e69b889claireho * and are designed to be chainable, i.e., applying ToASCII or ToUnicode operations
53127f654740f2a26ad62a5c155af9199af9e69b889claireho * multiple times to an input string will yield the same result as applying the operation
53227f654740f2a26ad62a5c155af9199af9e69b889claireho * once.
53327f654740f2a26ad62a5c155af9199af9e69b889claireho * ToUnicode(ToUnicode(ToUnicode...(ToUnicode(string)))) == ToUnicode(string)
53427f654740f2a26ad62a5c155af9199af9e69b889claireho * ToASCII(ToASCII(ToASCII...(ToASCII(string))) == ToASCII(string).
535b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
536b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param src               Input UChar array containing label in Unicode.
537b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.
538b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dest              Output UChar array with ASCII (ACE encoded) label.
539b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param destCapacity      Size of dest.
540b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options           A bit set of options:
541b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
542b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points
543b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              and do not use STD3 ASCII rules
544b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              If unassigned code points are found the operation fails with
545b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              U_UNASSIGNED_ERROR error code.
546b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
547b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  - UIDNA_ALLOW_UNASSIGNED    Unassigned values can be converted to ASCII for query operations
548b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              If this option is set, the unassigned code points are in the input
549b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              are treated as normal Unicode code points.
55027f654740f2a26ad62a5c155af9199af9e69b889claireho *
551b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions
552b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              If this option is set and the input does not satisfy STD3 rules,
553b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR
554b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
555b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param parseError        Pointer to UParseError struct to receive information on position
556b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          of error if an error is encountered. Can be NULL.
557b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status            ICU in/out error code parameter.
558b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          U_INVALID_CHAR_FOUND if src contains
559b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          unmatched single surrogates.
560b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
561b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          too many code points.
562b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
563b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The length of the result string, if successful - or in case of a buffer overflow,
564b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *         in which case it will be greater than destCapacity.
565b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.6
566b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
567b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int32_t U_EXPORT2
568b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruuidna_toASCII(const UChar* src, int32_t srcLength,
569b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              UChar* dest, int32_t destCapacity,
570b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              int32_t options,
571b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              UParseError* parseError,
572b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru              UErrorCode* status);
573b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
574b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
575b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
57627f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA2003: This function implements the ToUnicode operation as defined in the IDNA RFC.
577b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This operation is done on <b>single labels</b> before sending it to something that expects
578b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Unicode names. A label is an individual part of a domain name. Labels are usually
57950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * separated by dots; for e.g. "www.example.com" is composed of 3 labels "www","example", and "com".
580b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
581b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param src               Input UChar array containing ASCII (ACE encoded) label.
582b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.
583b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dest Output       Converted UChar array containing Unicode equivalent of label.
584b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param destCapacity      Size of dest.
585b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options           A bit set of options:
58627f654740f2a26ad62a5c155af9199af9e69b889claireho *
587b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points
588b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              and do not use STD3 ASCII rules
589b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              If unassigned code points are found the operation fails with
590b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              U_UNASSIGNED_ERROR error code.
591b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
592b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  - UIDNA_ALLOW_UNASSIGNED      Unassigned values can be converted to ASCII for query operations
593b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              If this option is set, the unassigned code points are in the input
594b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              are treated as normal Unicode code points. <b> Note: </b> This option is
595b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              required on toUnicode operation because the RFC mandates
596b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              verification of decoded ACE input by applying toASCII and comparing
597b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              its output with source
598b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
599b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions
600b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              If this option is set and the input does not satisfy STD3 rules,
601b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR
602b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
603b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param parseError        Pointer to UParseError struct to receive information on position
604b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          of error if an error is encountered. Can be NULL.
605b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status            ICU in/out error code parameter.
606b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          U_INVALID_CHAR_FOUND if src contains
607b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          unmatched single surrogates.
608b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
609b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          too many code points.
610b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
611b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The length of the result string, if successful - or in case of a buffer overflow,
612b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *         in which case it will be greater than destCapacity.
613b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.6
614b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
615b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int32_t U_EXPORT2
616b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruuidna_toUnicode(const UChar* src, int32_t srcLength,
617b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                UChar* dest, int32_t destCapacity,
618b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                int32_t options,
619b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                UParseError* parseError,
620b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                UErrorCode* status);
621b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
622b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
623b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
62427f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA2003: Convenience function that implements the IDNToASCII operation as defined in the IDNA RFC.
625b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This operation is done on complete domain names, e.g: "www.example.com".
626b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * It is important to note that this operation can fail. If it fails, then the input
627b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * domain name cannot be used as an Internationalized Domain Name and the application
628b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * should have methods defined to deal with the failure.
62927f654740f2a26ad62a5c155af9199af9e69b889claireho *
630b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <b>Note:</b> IDNA RFC specifies that a conformant application should divide a domain name
631b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each,
632b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and then convert. This function does not offer that level of granularity. The options once
633b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * set will apply to all labels in the domain name
634b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
635b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param src               Input UChar array containing IDN in Unicode.
636b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.
637b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dest              Output UChar array with ASCII (ACE encoded) IDN.
638b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param destCapacity      Size of dest.
639b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options           A bit set of options:
64027f654740f2a26ad62a5c155af9199af9e69b889claireho *
641b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points
642b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              and do not use STD3 ASCII rules
643b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              If unassigned code points are found the operation fails with
644b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              U_UNASSIGNED_CODE_POINT_FOUND error code.
645b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
646b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  - UIDNA_ALLOW_UNASSIGNED    Unassigned values can be converted to ASCII for query operations
647b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              If this option is set, the unassigned code points are in the input
648b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              are treated as normal Unicode code points.
64927f654740f2a26ad62a5c155af9199af9e69b889claireho *
650b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions
651b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              If this option is set and the input does not satisfy STD3 rules,
652b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR
65327f654740f2a26ad62a5c155af9199af9e69b889claireho *
654b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param parseError        Pointer to UParseError struct to receive information on position
655b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          of error if an error is encountered. Can be NULL.
656b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status            ICU in/out error code parameter.
657b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          U_INVALID_CHAR_FOUND if src contains
658b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          unmatched single surrogates.
659b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
660b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          too many code points.
661b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
662b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The length of the result string, if successful - or in case of a buffer overflow,
663b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *         in which case it will be greater than destCapacity.
664b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.6
665b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
666b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int32_t U_EXPORT2
667b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruuidna_IDNToASCII(  const UChar* src, int32_t srcLength,
668b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                   UChar* dest, int32_t destCapacity,
669b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                   int32_t options,
670b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                   UParseError* parseError,
671b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                   UErrorCode* status);
672b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
673b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
67427f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA2003: Convenience function that implements the IDNToUnicode operation as defined in the IDNA RFC.
675b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This operation is done on complete domain names, e.g: "www.example.com".
676b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
677b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * <b>Note:</b> IDNA RFC specifies that a conformant application should divide a domain name
678b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each,
679b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and then convert. This function does not offer that level of granularity. The options once
680b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * set will apply to all labels in the domain name
681b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
682b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param src               Input UChar array containing IDN in ASCII (ACE encoded) form.
683b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.
684b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dest Output       UChar array containing Unicode equivalent of source IDN.
685b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param destCapacity      Size of dest.
686b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options           A bit set of options:
68727f654740f2a26ad62a5c155af9199af9e69b889claireho *
688b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points
689b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              and do not use STD3 ASCII rules
690b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              If unassigned code points are found the operation fails with
691b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              U_UNASSIGNED_CODE_POINT_FOUND error code.
692b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
693b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  - UIDNA_ALLOW_UNASSIGNED    Unassigned values can be converted to ASCII for query operations
694b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              If this option is set, the unassigned code points are in the input
695b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              are treated as normal Unicode code points.
69627f654740f2a26ad62a5c155af9199af9e69b889claireho *
697b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions
698b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              If this option is set and the input does not satisfy STD3 rules,
699b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR
700b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
701b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param parseError        Pointer to UParseError struct to receive information on position
702b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          of error if an error is encountered. Can be NULL.
703b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status            ICU in/out error code parameter.
704b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          U_INVALID_CHAR_FOUND if src contains
705b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          unmatched single surrogates.
706b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
707b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          too many code points.
708b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
709b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return The length of the result string, if successful - or in case of a buffer overflow,
710b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *         in which case it will be greater than destCapacity.
711b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.6
712b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
713b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int32_t U_EXPORT2
714b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruuidna_IDNToUnicode(  const UChar* src, int32_t srcLength,
715b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                     UChar* dest, int32_t destCapacity,
716b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                     int32_t options,
717b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                     UParseError* parseError,
718b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                     UErrorCode* status);
719b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
720b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/**
72127f654740f2a26ad62a5c155af9199af9e69b889claireho * IDNA2003: Compare two IDN strings for equivalence.
722b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This function splits the domain names into labels and compares them.
723b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * According to IDN RFC, whenever two labels are compared, they are
724b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * considered equal if and only if their ASCII forms (obtained by
725b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * applying toASCII) match using an case-insensitive ASCII comparison.
726b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Two domain names are considered a match if and only if all labels
727b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * match regardless of whether label separators match.
728b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
729b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param s1                First source string.
730b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length1           Length of first source string, or -1 if NUL-terminated.
731b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
732b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param s2                Second source string.
733b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length2           Length of second source string, or -1 if NUL-terminated.
734b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param options           A bit set of options:
73527f654740f2a26ad62a5c155af9199af9e69b889claireho *
736b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points
737b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              and do not use STD3 ASCII rules
738b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              If unassigned code points are found the operation fails with
739b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              U_UNASSIGNED_CODE_POINT_FOUND error code.
740b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
741b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  - UIDNA_ALLOW_UNASSIGNED    Unassigned values can be converted to ASCII for query operations
742b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              If this option is set, the unassigned code points are in the input
743b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              are treated as normal Unicode code points.
74427f654740f2a26ad62a5c155af9199af9e69b889claireho *
745b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions
746b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              If this option is set and the input does not satisfy STD3 rules,
747b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR
748b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *
749b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param status            ICU error code in/out parameter.
750b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru *                          Must fulfill U_SUCCESS before the function call.
751b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return <0 or 0 or >0 as usual for string comparisons
752b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @stable ICU 2.6
753b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */
754b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_STABLE int32_t U_EXPORT2
755b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruuidna_compare(  const UChar *s1, int32_t length1,
756b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                const UChar *s2, int32_t length2,
757b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                int32_t options,
758b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru                UErrorCode* status);
759b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
760b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif /* #if !UCONFIG_NO_IDNA */
761b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru
762b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif
763