]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/unicode/uidna.h
ICU-59173.0.1.tar.gz
[apple/icu.git] / icuSources / common / unicode / uidna.h
index 04b439d970f45824ab9fe8c7ef477106334ead1d..13e147234c7091c189df05b3b4816b9eefe53e34 100644 (file)
@@ -1,12 +1,14 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
  *******************************************************************************
  *
- *   Copyright (C) 2003-2010, International Business Machines
+ *   Copyright (C) 2003-2014, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  *******************************************************************************
  *   file name:  uidna.h
- *   encoding:   US-ASCII
+ *   encoding:   UTF-8
  *   tab size:   8 (not used)
  *   indentation:4
  *
  *
  * The C API functions which do take a UIDNA * service object pointer
  * implement UTS #46 and IDNA2008.
+ *
+ * IDNA2003 is obsolete.
  * The C API functions which do not take a service object pointer
- * implement IDNA2003.
+ * implement IDNA2003. They are all deprecated.
  */
 
 /*
 enum {
     /**
      * Default options value: None of the other options are set.
+     * For use in static worker and factory methods.
      * @stable ICU 2.6
      */
     UIDNA_DEFAULT=0,
+#ifndef U_HIDE_DEPRECATED_API
     /**
      * Option to allow unassigned code points in domain names and labels.
-     * This option is ignored by the UTS46 implementation.
+     * For use in static worker and factory methods.
+     * <p>This option is ignored by the UTS46 implementation.
      * (UTS #46 disallows unassigned code points.)
-     * @stable ICU 2.6
+     * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA.
      */
     UIDNA_ALLOW_UNASSIGNED=1,
+#endif  /* U_HIDE_DEPRECATED_API */
     /**
      * Option to check whether the input conforms to the STD3 ASCII rules,
      * for example the restriction of labels to LDH characters
      * (ASCII Letters, Digits and Hyphen-Minus).
+     * For use in static worker and factory methods.
      * @stable ICU 2.6
      */
     UIDNA_USE_STD3_RULES=2,
     /**
      * IDNA option to check for whether the input conforms to the BiDi rules.
-     * This option is ignored by the IDNA2003 implementation.
+     * For use in static worker and factory methods.
+     * <p>This option is ignored by the IDNA2003 implementation.
      * (IDNA2003 always performs a BiDi check.)
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     UIDNA_CHECK_BIDI=4,
     /**
      * IDNA option to check for whether the input conforms to the CONTEXTJ rules.
-     * This option is ignored by the IDNA2003 implementation.
+     * For use in static worker and factory methods.
+     * <p>This option is ignored by the IDNA2003 implementation.
      * (The CONTEXTJ check is new in IDNA2008.)
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     UIDNA_CHECK_CONTEXTJ=8,
     /**
      * IDNA option for nontransitional processing in ToASCII().
-     * By default, ToASCII() uses transitional processing.
-     * This option is ignored by the IDNA2003 implementation.
+     * For use in static worker and factory methods.
+     * <p>By default, ToASCII() uses transitional processing.
+     * <p>This option is ignored by the IDNA2003 implementation.
      * (This is only relevant for compatibility of newer IDNA implementations with IDNA2003.)
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     UIDNA_NONTRANSITIONAL_TO_ASCII=0x10,
     /**
      * IDNA option for nontransitional processing in ToUnicode().
-     * By default, ToUnicode() uses transitional processing.
-     * This option is ignored by the IDNA2003 implementation.
+     * For use in static worker and factory methods.
+     * <p>By default, ToUnicode() uses transitional processing.
+     * <p>This option is ignored by the IDNA2003 implementation.
      * (This is only relevant for compatibility of newer IDNA implementations with IDNA2003.)
-     * @draft ICU 4.6
+     * @stable ICU 4.6
+     */
+    UIDNA_NONTRANSITIONAL_TO_UNICODE=0x20,
+    /**
+     * IDNA option to check for whether the input conforms to the CONTEXTO rules.
+     * For use in static worker and factory methods.
+     * <p>This option is ignored by the IDNA2003 implementation.
+     * (The CONTEXTO check is new in IDNA2008.)
+     * <p>This is for use by registries for IDNA2008 conformance.
+     * UTS #46 does not require the CONTEXTO check.
+     * @stable ICU 49
      */
-    UIDNA_NONTRANSITIONAL_TO_UNICODE=0x20
+    UIDNA_CHECK_CONTEXTO=0x40
 };
 
 /**
  * Opaque C service object type for the new IDNA API.
- * @draft ICU 4.6
+ * @stable ICU 4.6
  */
 struct UIDNA;
-typedef struct UIDNA UIDNA;  /**< C typedef for struct UIDNA. @draft ICU 4.6 */
+typedef struct UIDNA UIDNA;  /**< C typedef for struct UIDNA. @stable ICU 4.6 */
 
 /**
  * Returns a UIDNA instance which implements UTS #46.
@@ -113,17 +136,17 @@ typedef struct UIDNA UIDNA;  /**< C typedef for struct UIDNA. @draft ICU 4.6 */
  *                  immediately. Check for U_FAILURE() on output or use with
  *                  function chaining. (See User Guide for details.)
  * @return the UTS #46 UIDNA instance, if successful
- * @draft ICU 4.6
+ * @stable ICU 4.6
  */
-U_DRAFT UIDNA * U_EXPORT2
+U_STABLE UIDNA * U_EXPORT2
 uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode);
 
 /**
  * Closes a UIDNA instance.
  * @param idna UIDNA instance to be closed
- * @draft ICU 4.6
+ * @stable ICU 4.6
  */
-U_DRAFT void U_EXPORT2
+U_STABLE void U_EXPORT2
 uidna_close(UIDNA *idna);
 
 #if U_SHOW_CPLUSPLUS_API
@@ -137,13 +160,13 @@ U_NAMESPACE_BEGIN
  *
  * @see LocalPointerBase
  * @see LocalPointer
- * @draft ICU 4.6
+ * @stable ICU 4.6
  */
 U_DEFINE_LOCAL_OPEN_POINTER(LocalUIDNAPointer, UIDNA, uidna_close);
 
 U_NAMESPACE_END
 
-#endif
+#endif // U_SHOW_CPLUSPLUS_API
 
 /**
  * Output container for IDNA processing errors.
@@ -153,32 +176,31 @@ U_NAMESPACE_END
  * int32_t length = uidna_nameToASCII(..., &info, &errorCode);
  * if(U_SUCCESS(errorCode) && info.errors!=0) { ... }
  * \endcode
- * @draft ICU 4.6
+ * @stable ICU 4.6
  */
-struct UIDNAInfo {
-    /** sizeof(UIDNAInfo) @draft ICU 4.6 */
+typedef struct UIDNAInfo {
+    /** sizeof(UIDNAInfo) @stable ICU 4.6 */
     int16_t size;
     /**
      * Set to TRUE if transitional and nontransitional processing produce different results.
      * For details see C++ IDNAInfo::isTransitionalDifferent().
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     UBool isTransitionalDifferent;
     UBool reservedB3;  /**< Reserved field, do not use. @internal */
     /**
      * Bit set indicating IDNA processing errors. 0 if no errors.
      * See UIDNA_ERROR_... constants.
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     uint32_t errors;
     int32_t reservedI2;  /**< Reserved field, do not use. @internal */
     int32_t reservedI3;  /**< Reserved field, do not use. @internal */
-};
-typedef struct UIDNAInfo UIDNAInfo;
+} UIDNAInfo;
 
 /**
  * Static initializer for a UIDNAInfo struct.
- * @draft ICU 4.6
+ * @stable ICU 4.6
  */
 #define UIDNA_INFO_INITIALIZER { \
     (int16_t)sizeof(UIDNAInfo), \
@@ -206,9 +228,9 @@ typedef struct UIDNAInfo UIDNAInfo;
  *                  immediately. Check for U_FAILURE() on output or use with
  *                  function chaining. (See User Guide for details.)
  * @return destination string length
- * @draft ICU 4.6
+ * @stable ICU 4.6
  */
-U_DRAFT int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 uidna_labelToASCII(const UIDNA *idna,
                    const UChar *label, int32_t length,
                    UChar *dest, int32_t capacity,
@@ -233,9 +255,9 @@ uidna_labelToASCII(const UIDNA *idna,
  *                  immediately. Check for U_FAILURE() on output or use with
  *                  function chaining. (See User Guide for details.)
  * @return destination string length
- * @draft ICU 4.6
+ * @stable ICU 4.6
  */
-U_DRAFT int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 uidna_labelToUnicode(const UIDNA *idna,
                      const UChar *label, int32_t length,
                      UChar *dest, int32_t capacity,
@@ -262,9 +284,9 @@ uidna_labelToUnicode(const UIDNA *idna,
  *                  immediately. Check for U_FAILURE() on output or use with
  *                  function chaining. (See User Guide for details.)
  * @return destination string length
- * @draft ICU 4.6
+ * @stable ICU 4.6
  */
-U_DRAFT int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 uidna_nameToASCII(const UIDNA *idna,
                   const UChar *name, int32_t length,
                   UChar *dest, int32_t capacity,
@@ -289,9 +311,9 @@ uidna_nameToASCII(const UIDNA *idna,
  *                  immediately. Check for U_FAILURE() on output or use with
  *                  function chaining. (See User Guide for details.)
  * @return destination string length
- * @draft ICU 4.6
+ * @stable ICU 4.6
  */
-U_DRAFT int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 uidna_nameToUnicode(const UIDNA *idna,
                     const UChar *name, int32_t length,
                     UChar *dest, int32_t capacity,
@@ -314,9 +336,9 @@ uidna_nameToUnicode(const UIDNA *idna,
  *                  immediately. Check for U_FAILURE() on output or use with
  *                  function chaining. (See User Guide for details.)
  * @return destination string length
- * @draft ICU 4.6
+ * @stable ICU 4.6
  */
-U_DRAFT int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 uidna_labelToASCII_UTF8(const UIDNA *idna,
                         const char *label, int32_t length,
                         char *dest, int32_t capacity,
@@ -337,9 +359,9 @@ uidna_labelToASCII_UTF8(const UIDNA *idna,
  *                  immediately. Check for U_FAILURE() on output or use with
  *                  function chaining. (See User Guide for details.)
  * @return destination string length
- * @draft ICU 4.6
+ * @stable ICU 4.6
  */
-U_DRAFT int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 uidna_labelToUnicodeUTF8(const UIDNA *idna,
                          const char *label, int32_t length,
                          char *dest, int32_t capacity,
@@ -360,9 +382,9 @@ uidna_labelToUnicodeUTF8(const UIDNA *idna,
  *                  immediately. Check for U_FAILURE() on output or use with
  *                  function chaining. (See User Guide for details.)
  * @return destination string length
- * @draft ICU 4.6
+ * @stable ICU 4.6
  */
-U_DRAFT int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 uidna_nameToASCII_UTF8(const UIDNA *idna,
                        const char *name, int32_t length,
                        char *dest, int32_t capacity,
@@ -383,9 +405,9 @@ uidna_nameToASCII_UTF8(const UIDNA *idna,
  *                  immediately. Check for U_FAILURE() on output or use with
  *                  function chaining. (See User Guide for details.)
  * @return destination string length
- * @draft ICU 4.6
+ * @stable ICU 4.6
  */
-U_DRAFT int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 uidna_nameToUnicodeUTF8(const UIDNA *idna,
                         const char *name, int32_t length,
                         char *dest, int32_t capacity,
@@ -399,58 +421,58 @@ uidna_nameToUnicodeUTF8(const UIDNA *idna,
 enum {
     /**
      * A non-final domain name label (or the whole domain name) is empty.
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     UIDNA_ERROR_EMPTY_LABEL=1,
     /**
      * A domain name label is longer than 63 bytes.
      * (See STD13/RFC1034 3.1. Name space specifications and terminology.)
      * This is only checked in ToASCII operations, and only if the output label is all-ASCII.
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     UIDNA_ERROR_LABEL_TOO_LONG=2,
     /**
      * A domain name is longer than 255 bytes in its storage form.
      * (See STD13/RFC1034 3.1. Name space specifications and terminology.)
      * This is only checked in ToASCII operations, and only if the output domain name is all-ASCII.
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     UIDNA_ERROR_DOMAIN_NAME_TOO_LONG=4,
     /**
      * A label starts with a hyphen-minus ('-').
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     UIDNA_ERROR_LEADING_HYPHEN=8,
     /**
      * A label ends with a hyphen-minus ('-').
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     UIDNA_ERROR_TRAILING_HYPHEN=0x10,
     /**
      * A label contains hyphen-minus ('-') in the third and fourth positions.
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     UIDNA_ERROR_HYPHEN_3_4=0x20,
     /**
      * A label starts with a combining mark.
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     UIDNA_ERROR_LEADING_COMBINING_MARK=0x40,
     /**
      * A label or domain name contains disallowed characters.
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     UIDNA_ERROR_DISALLOWED=0x80,
     /**
      * A label starts with "xn--" but does not contain valid Punycode.
      * That is, an xn-- label failed Punycode decoding.
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     UIDNA_ERROR_PUNYCODE=0x100,
     /**
      * A label contains a dot=full stop.
      * This can occur in an input string for a single-label function.
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     UIDNA_ERROR_LABEL_HAS_DOT=0x200,
     /**
@@ -459,21 +481,36 @@ enum {
      * string had severe validation errors. For example,
      * it might contain characters that are not allowed in ACE labels,
      * or it might not be normalized.
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     UIDNA_ERROR_INVALID_ACE_LABEL=0x400,
     /**
      * A label does not meet the IDNA BiDi requirements (for right-to-left characters).
-     * @draft ICU 4.6
+     * @stable ICU 4.6
      */
     UIDNA_ERROR_BIDI=0x800,
     /**
      * A label does not meet the IDNA CONTEXTJ requirements.
-     * @draft ICU 4.6
+     * @stable ICU 4.6
+     */
+    UIDNA_ERROR_CONTEXTJ=0x1000,
+    /**
+     * A label does not meet the IDNA CONTEXTO requirements for punctuation characters.
+     * Some punctuation characters "Would otherwise have been DISALLOWED"
+     * but are allowed in certain contexts. (RFC 5892)
+     * @stable ICU 49
      */
-    UIDNA_ERROR_CONTEXTJ=0x1000
+    UIDNA_ERROR_CONTEXTO_PUNCTUATION=0x2000,
+    /**
+     * A label does not meet the IDNA CONTEXTO requirements for digits.
+     * Arabic-Indic Digits (U+066x) must not be mixed with Extended Arabic-Indic Digits (U+06Fx).
+     * @stable ICU 49
+     */
+    UIDNA_ERROR_CONTEXTO_DIGITS=0x4000
 };
 
+#ifndef U_HIDE_DEPRECATED_API
+
 /* IDNA2003 API ------------------------------------------------------------- */
 
 /**
@@ -533,9 +570,9 @@ enum {
  *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
  * @return The length of the result string, if successful - or in case of a buffer overflow,
  *         in which case it will be greater than destCapacity.
- * @stable ICU 2.6
+ * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA.
  */
-U_STABLE int32_t U_EXPORT2
+U_DEPRECATED int32_t U_EXPORT2
 uidna_toASCII(const UChar* src, int32_t srcLength, 
               UChar* dest, int32_t destCapacity,
               int32_t options,
@@ -581,9 +618,9 @@ uidna_toASCII(const UChar* src, int32_t srcLength,
  *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
  * @return The length of the result string, if successful - or in case of a buffer overflow,
  *         in which case it will be greater than destCapacity.
- * @stable ICU 2.6
+ * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA.
  */
-U_STABLE int32_t U_EXPORT2
+U_DEPRECATED int32_t U_EXPORT2
 uidna_toUnicode(const UChar* src, int32_t srcLength,
                 UChar* dest, int32_t destCapacity,
                 int32_t options,
@@ -632,9 +669,9 @@ uidna_toUnicode(const UChar* src, int32_t srcLength,
  *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
  * @return The length of the result string, if successful - or in case of a buffer overflow,
  *         in which case it will be greater than destCapacity.
- * @stable ICU 2.6
+ * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA.
  */
-U_STABLE int32_t U_EXPORT2
+U_DEPRECATED int32_t U_EXPORT2
 uidna_IDNToASCII(  const UChar* src, int32_t srcLength,
                    UChar* dest, int32_t destCapacity,
                    int32_t options,
@@ -679,9 +716,9 @@ uidna_IDNToASCII(  const UChar* src, int32_t srcLength,
  *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
  * @return The length of the result string, if successful - or in case of a buffer overflow,
  *         in which case it will be greater than destCapacity.
- * @stable ICU 2.6
+ * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA.
  */
-U_STABLE int32_t U_EXPORT2
+U_DEPRECATED int32_t U_EXPORT2
 uidna_IDNToUnicode(  const UChar* src, int32_t srcLength,
                      UChar* dest, int32_t destCapacity,
                      int32_t options,
@@ -720,14 +757,16 @@ uidna_IDNToUnicode(  const UChar* src, int32_t srcLength,
  * @param status            ICU error code in/out parameter.
  *                          Must fulfill U_SUCCESS before the function call.
  * @return <0 or 0 or >0 as usual for string comparisons
- * @stable ICU 2.6
+ * @deprecated ICU 55 Use UTS #46 instead via uidna_openUTS46() or class IDNA.
  */
-U_STABLE int32_t U_EXPORT2
+U_DEPRECATED int32_t U_EXPORT2
 uidna_compare(  const UChar *s1, int32_t length1,
                 const UChar *s2, int32_t length2,
                 int32_t options,
                 UErrorCode* status);
 
+#endif  /* U_HIDE_DEPRECATED_API */
+
 #endif /* #if !UCONFIG_NO_IDNA */
 
 #endif