Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 09:25:43

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