18e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/*
28e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *******************************************************************************
38e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
48e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *   Copyright (C) 2003-2004, International Business Machines
58e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *   Corporation and others.  All Rights Reserved.
68e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
78e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *******************************************************************************
88e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *   file name:  uidna.h
98e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *   encoding:   US-ASCII
108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *   tab size:   8 (not used)
118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *   indentation:4
128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *   created on: 2003feb1
148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *   created by: Ram Viswanadha
158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#ifndef __UIDNA_H__
188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#define __UIDNA_H__
198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "unicode/utypes.h"
218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#if !UCONFIG_NO_IDNA
238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#include "unicode/parseerr.h"
258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *\file
288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * UIDNA API implements the IDNA protocol as defined in the IDNA RFC
298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (http://www.ietf.org/rfc/rfc3490.txt).
308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The RFC defines 2 operations: ToASCII and ToUnicode. Domain labels
318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * containing non-ASCII code points are required to be processed by
328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * ToASCII operation before passing it to resolver libraries. Domain names
338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * that are obtained from resolver libraries are required to be processed by
348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * ToUnicode operation before displaying the domain name to the user.
358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * IDNA requires that implementations process input strings with Nameprep
368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * (http://www.ietf.org/rfc/rfc3491.txt),
378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * which is a profile of Stringprep (http://www.ietf.org/rfc/rfc3454.txt),
388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * and then with Punycode (http://www.ietf.org/rfc/rfc3492.txt).
398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Implementations of IDNA MUST fully implement Nameprep and Punycode;
408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * neither Nameprep nor Punycode are optional.
418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * The input and output of ToASCII and ToUnicode operations are Unicode
428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * and are designed to be chainable, i.e., applying ToASCII or ToUnicode operations
438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * multiple times to an input string will yield the same result as applying the operation
448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * once.
458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * ToUnicode(ToUnicode(ToUnicode...(ToUnicode(string)))) == ToUnicode(string)
468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * ToASCII(ToASCII(ToASCII...(ToASCII(string))) == ToASCII(string).
478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#ifndef U_HIDE_DRAFT_API
518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Option to prohibit processing of unassigned codepoints in the input and
548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * do not check if the input conforms to STD-3 ASCII rules.
558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see  uidna_toASCII uidna_toUnicode
578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.6
588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#define UIDNA_DEFAULT          0x0000
608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Option to allow processing of unassigned codepoints in the input
628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see  uidna_toASCII uidna_toUnicode
648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.6
658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#define UIDNA_ALLOW_UNASSIGNED 0x0001
678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
688e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Option to check if input conforms to STD-3 ASCII rules
698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @see  uidna_toASCII uidna_toUnicode
718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.6
728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#define UIDNA_USE_STD3_RULES   0x0002
748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif /*U_HIDE_DRAFT_API*/
768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This function implements the ToASCII operation as defined in the IDNA RFC.
798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This operation is done on <b>single labels</b> before sending it to something that expects
808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * ASCII names. A label is an individual part of a domain name. Labels are usually
818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * separated by dots; e.g." "www.example.com" is composed of 3 labels
828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * "www","example", and "com".
838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
848e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param src               Input UChar array containing label in Unicode.
868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.
878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param dest              Output UChar array with ASCII (ACE encoded) label.
888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param destCapacity      Size of dest.
898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param options           A bit set of options:
908e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points
928e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              and do not use STD3 ASCII rules
938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              If unassigned code points are found the operation fails with
948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              U_UNASSIGNED_ERROR error code.
958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *  - UIDNA_ALLOW_UNASSIGNED    Unassigned values can be converted to ASCII for query operations
978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              If this option is set, the unassigned code points are in the input
988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              are treated as normal Unicode code points.
998e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1008e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions
1018e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              If this option is set and the input does not satisfy STD3 rules,
1028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR
1038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param parseError        Pointer to UParseError struct to receive information on position
1058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          of error if an error is encountered. Can be NULL.
1068e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param status            ICU in/out error code parameter.
1078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          U_INVALID_CHAR_FOUND if src contains
1088e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          unmatched single surrogates.
1098e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
1108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          too many code points.
1118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
1128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return                  Number of ASCII characters converted.
1138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.6
1148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
1158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_STABLE int32_t U_EXPORT2
1168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectuidna_toASCII(const UChar* src, int32_t srcLength,
1178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project              UChar* dest, int32_t destCapacity,
1188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project              int32_t options,
1198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project              UParseError* parseError,
1208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project              UErrorCode* status);
1218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
1228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
1238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
1248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This function implements the ToUnicode operation as defined in the IDNA RFC.
1258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This operation is done on <b>single labels</b> before sending it to something that expects
1268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Unicode names. A label is an individual part of a domain name. Labels are usually
1278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * separated by dots; for e.g." "www.example.com" is composed of 3 labels
1288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * "www","example", and "com".
1298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param src               Input UChar array containing ASCII (ACE encoded) label.
1318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.
1328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param dest Output       Converted UChar array containing Unicode equivalent of label.
1338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param destCapacity      Size of dest.
1348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param options           A bit set of options:
1358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points
1378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              and do not use STD3 ASCII rules
1388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              If unassigned code points are found the operation fails with
1398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              U_UNASSIGNED_ERROR error code.
1408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *  - UIDNA_ALLOW_UNASSIGNED      Unassigned values can be converted to ASCII for query operations
1428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              If this option is set, the unassigned code points are in the input
1438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              are treated as normal Unicode code points. <b> Note: </b> This option is
1448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              required on toUnicode operation because the RFC mandates
1458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              verification of decoded ACE input by applying toASCII and comparing
1468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              its output with source
1478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions
1518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              If this option is set and the input does not satisfy STD3 rules,
1528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR
1538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param parseError        Pointer to UParseError struct to receive information on position
1558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          of error if an error is encountered. Can be NULL.
1568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param status            ICU in/out error code parameter.
1578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          U_INVALID_CHAR_FOUND if src contains
1588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          unmatched single surrogates.
1598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
1608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          too many code points.
1618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
1628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return                  Number of Unicode characters converted.
1638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.6
1648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
1658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_STABLE int32_t U_EXPORT2
1668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectuidna_toUnicode(const UChar* src, int32_t srcLength,
1678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project                UChar* dest, int32_t destCapacity,
1688e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project                int32_t options,
1698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project                UParseError* parseError,
1708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project                UErrorCode* status);
1718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
1728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
1738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
1748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Convenience function that implements the IDNToASCII operation as defined in the IDNA RFC.
1758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This operation is done on complete domain names, e.g: "www.example.com".
1768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * It is important to note that this operation can fail. If it fails, then the input
1778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * domain name cannot be used as an Internationalized Domain Name and the application
1788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * should have methods defined to deal with the failure.
1798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * <b>Note:</b> IDNA RFC specifies that a conformant application should divide a domain name
1818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each,
1828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * and then convert. This function does not offer that level of granularity. The options once
1838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * set will apply to all labels in the domain name
1848e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param src               Input UChar array containing IDN in Unicode.
1868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.
1878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param dest              Output UChar array with ASCII (ACE encoded) IDN.
1888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param destCapacity      Size of dest.
1898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param options           A bit set of options:
1908e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points
1928e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              and do not use STD3 ASCII rules
1938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              If unassigned code points are found the operation fails with
1948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              U_UNASSIGNED_CODE_POINT_FOUND error code.
1958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
1968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *  - UIDNA_ALLOW_UNASSIGNED    Unassigned values can be converted to ASCII for query operations
1978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              If this option is set, the unassigned code points are in the input
1988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              are treated as normal Unicode code points.
1998e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2008e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions
2018e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              If this option is set and the input does not satisfy STD3 rules,
2028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR
2038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param parseError        Pointer to UParseError struct to receive information on position
2058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          of error if an error is encountered. Can be NULL.
2068e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param status            ICU in/out error code parameter.
2078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          U_INVALID_CHAR_FOUND if src contains
2088e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          unmatched single surrogates.
2098e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
2108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          too many code points.
2118e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
2128e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return                  Number of ASCII characters converted.
2138e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.6
2148e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
2158e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_STABLE int32_t U_EXPORT2
2168e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectuidna_IDNToASCII(  const UChar* src, int32_t srcLength,
2178e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project                   UChar* dest, int32_t destCapacity,
2188e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project                   int32_t options,
2198e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project                   UParseError* parseError,
2208e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project                   UErrorCode* status);
2218e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
2228e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
2238e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Convenience function that implements the IDNToUnicode operation as defined in the IDNA RFC.
2248e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This operation is done on complete domain names, e.g: "www.example.com".
2258e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2268e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * <b>Note:</b> IDNA RFC specifies that a conformant application should divide a domain name
2278e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each,
2288e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * and then convert. This function does not offer that level of granularity. The options once
2298e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * set will apply to all labels in the domain name
2308e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2318e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param src               Input UChar array containing IDN in ASCII (ACE encoded) form.
2328e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.
2338e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param dest Output       UChar array containing Unicode equivalent of source IDN.
2348e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param destCapacity      Size of dest.
2358e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param options           A bit set of options:
2368e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2378e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points
2388e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              and do not use STD3 ASCII rules
2398e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              If unassigned code points are found the operation fails with
2408e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              U_UNASSIGNED_CODE_POINT_FOUND error code.
2418e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2428e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *  - UIDNA_ALLOW_UNASSIGNED    Unassigned values can be converted to ASCII for query operations
2438e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              If this option is set, the unassigned code points are in the input
2448e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              are treated as normal Unicode code points.
2458e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2468e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions
2478e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              If this option is set and the input does not satisfy STD3 rules,
2488e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR
2498e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2508e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param parseError        Pointer to UParseError struct to receive information on position
2518e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          of error if an error is encountered. Can be NULL.
2528e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param status            ICU in/out error code parameter.
2538e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          U_INVALID_CHAR_FOUND if src contains
2548e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          unmatched single surrogates.
2558e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
2568e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          too many code points.
2578e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
2588e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return                  Number of ASCII characters converted.
2598e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.6
2608e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
2618e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_STABLE int32_t U_EXPORT2
2628e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectuidna_IDNToUnicode(  const UChar* src, int32_t srcLength,
2638e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project                     UChar* dest, int32_t destCapacity,
2648e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project                     int32_t options,
2658e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project                     UParseError* parseError,
2668e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project                     UErrorCode* status);
2678e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
2688e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project/**
2698e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Compare two IDN strings for equivalence.
2708e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * This function splits the domain names into labels and compares them.
2718e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * According to IDN RFC, whenever two labels are compared, they are
2728e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * considered equal if and only if their ASCII forms (obtained by
2738e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * applying toASCII) match using an case-insensitive ASCII comparison.
2748e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * Two domain names are considered a match if and only if all labels
2758e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * match regardless of whether label separators match.
2768e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2778e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param s1                First source string.
2788e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param length1           Length of first source string, or -1 if NUL-terminated.
2798e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2808e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param s2                Second source string.
2818e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param length2           Length of second source string, or -1 if NUL-terminated.
2828e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param options           A bit set of options:
2838e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2848e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *  - UIDNA_DEFAULT             Use default options, i.e., do not process unassigned code points
2858e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              and do not use STD3 ASCII rules
2868e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              If unassigned code points are found the operation fails with
2878e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              U_UNASSIGNED_CODE_POINT_FOUND error code.
2888e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2898e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *  - UIDNA_ALLOW_UNASSIGNED    Unassigned values can be converted to ASCII for query operations
2908e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              If this option is set, the unassigned code points are in the input
2918e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              are treated as normal Unicode code points.
2928e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2938e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *  - UIDNA_USE_STD3_RULES      Use STD3 ASCII rules for host name syntax restrictions
2948e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              If this option is set and the input does not satisfy STD3 rules,
2958e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                              the operation will fail with U_IDNA_STD3_ASCII_RULES_ERROR
2968e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *
2978e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @param status            ICU error code in/out parameter.
2988e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project *                          Must fulfill U_SUCCESS before the function call.
2998e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @return <0 or 0 or >0 as usual for string comparisons
3008e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project * @stable ICU 2.6
3018e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project */
3028e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source ProjectU_STABLE int32_t U_EXPORT2
3038e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Projectuidna_compare(  const UChar *s1, int32_t length1,
3048e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project                const UChar *s2, int32_t length2,
3058e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project                int32_t options,
3068e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project                UErrorCode* status);
3078e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
3088e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif /* #if !UCONFIG_NO_IDNA */
3098e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project
3108e35f3cfc7fba1d1c829dc557ebad6409cbe16a2The Android Open Source Project#endif
311