10596faeddefbf198de137d5e893708495ab1584cFredrik Roubert// © 2016 and later: Unicode, Inc. and others.
264339d36f8bd4db5025fe2988eda22b491a9219cFredrik Roubert// License & terms of use: http://www.unicode.org/copyright.html
3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/*
4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *******************************************************************************
5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
6b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho *   Copyright (C) 2003-2011, International Business Machines
7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *   Corporation and others.  All Rights Reserved.
8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *******************************************************************************
10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *   file name:  idnaref.h
110596faeddefbf198de137d5e893708495ab1584cFredrik Roubert *   encoding:   UTF-8
12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *   tab size:   8 (not used)
13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *   indentation:4
14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *   created on: 2003feb1
16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *   created by: Ram Viswanadha
17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef __IDNAREF_H__
20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define __IDNAREF_H__
21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utypes.h"
23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if !UCONFIG_NO_IDNA
25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/parseerr.h"
27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define IDNAREF_DEFAULT          0x0000
29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define IDNAREF_ALLOW_UNASSIGNED 0x0001
30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define IDNAREF_USE_STD3_RULES   0x0002
31b26ce3a7367e4ed2ee7ddddcdc3f3d3377a455c2claireho
32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This function implements the ToASCII operation as defined in the IDNA draft.
34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This operation is done on <b>single labels</b> before sending it to something that expects
35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * ASCII names. A label is an individual part of a domain name. Labels are usually
36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * separated by dots; for e.g." "www.example.com" is composed of 3 labels
37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * "www","example", and "com".
38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param src               Input Unicode label.
41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.
42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param dest              Output Unicode array with ACE encoded ASCII label.
43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param destCapacity      Size of dest.
44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param options           A bit set of options:
45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  - idnaref_UNASSIGNED        Unassigned values can be converted to ASCII for query operations
47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          If TRUE unassigned values are treated as normal Unicode code points.
48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          If FALSE the operation fails with U_UNASSIGNED_CODE_POINT_FOUND error code.
49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  - idnaref_USE_STD3_RULES    Use STD3 ASCII rules for host name syntax restrictions
50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          If TRUE and the input does not statisfy STD3 rules, the operation
51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          will fail with U_IDNA_STD3_ASCII_RULES_ERROR
52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param parseError        Pointer to UParseError struct to recieve information on position
54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          of error if an error is encountered. Can be NULL.
55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status            ICU in/out error code parameter.
56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          U_INVALID_CHAR_FOUND if src contains
57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          unmatched single surrogates.
58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          too many code points.
60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return                  Number of ASCII characters converted.
62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CFUNC int32_t U_EXPORT2
64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruidnaref_toASCII(const UChar* src, int32_t srcLength,
65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru              UChar* dest, int32_t destCapacity,
66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru              int32_t options,
67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru              UParseError* parseError,
68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru              UErrorCode* status);
69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This function implements the ToUnicode operation as defined in the IDNA draft.
73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This operation is done on <b>single labels</b> before sending it to something that expects
74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * ASCII names. A label is an individual part of a domain name. Labels are usually
75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * separated by dots; for e.g." "www.example.com" is composed of 3 labels
76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * "www","example", and "com".
77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param src               Input ASCII (ACE encoded) label.
79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.
80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param dest Output       Converted Unicode array.
81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param destCapacity      Size of dest.
82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param options           A bit set of options:
83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  - idnaref_UNASSIGNED        Unassigned values can be converted to ASCII for query operations
85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          If TRUE unassigned values are treated as normal Unicode code points.
86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          If FALSE the operation fails with U_UNASSIGNED_CODE_POINT_FOUND error code.
87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  - idnaref_USE_STD3_RULES    Use STD3 ASCII rules for host name syntax restrictions
88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          If TRUE and the input does not statisfy STD3 rules, the operation
89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          will fail with U_IDNA_STD3_ASCII_RULES_ERROR
90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param parseError        Pointer to UParseError struct to recieve information on position
92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          of error if an error is encountered. Can be NULL.
93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status            ICU in/out error code parameter.
94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          U_INVALID_CHAR_FOUND if src contains
95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          unmatched single surrogates.
96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          too many code points.
98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return                  Number of Unicode characters converted.
100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CFUNC int32_t U_EXPORT2
102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruidnaref_toUnicode(const UChar* src, int32_t srcLength,
103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UChar* dest, int32_t destCapacity,
104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                int32_t options,
105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UParseError* parseError,
106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UErrorCode* status);
107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Convenience function that implements the IDNToASCII operation as defined in the IDNA draft.
111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This operation is done on complete domain names, e.g: "www.example.com".
112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * It is important to note that this operation can fail. If it fails, then the input
113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * domain name cannot be used as an Internationalized Domain Name and the application
114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * should have methods defined to deal with the failure.
115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <b>Note:</b> IDNA draft specifies that a conformant application should divide a domain name
117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each,
118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and then convert. This function does not offer that level of granularity. The options once
119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * set will apply to all labels in the domain name
120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param src               Input ASCII IDN.
122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.
123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param dest Output       Unicode array.
124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param destCapacity      Size of dest.
125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param options           A bit set of options:
126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  - idnaref_UNASSIGNED        Unassigned values can be converted to ASCII for query operations
128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          If TRUE unassigned values are treated as normal Unicode code points.
129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          If FALSE the operation fails with U_UNASSIGNED_CODE_POINT_FOUND error code.
130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  - idnaref_USE_STD3_RULES    Use STD3 ASCII rules for host name syntax restrictions
131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          If TRUE and the input does not statisfy STD3 rules, the operation
132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          will fail with U_IDNA_STD3_ASCII_RULES_ERROR
133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param parseError        Pointer to UParseError struct to recieve information on position
135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          of error if an error is encountered. Can be NULL.
136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status            ICU in/out error code parameter.
137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          U_INVALID_CHAR_FOUND if src contains
138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          unmatched single surrogates.
139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          too many code points.
141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return                  Number of ASCII characters converted.
143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CFUNC int32_t U_EXPORT2
145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruidnaref_IDNToASCII(  const UChar* src, int32_t srcLength,
146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                   UChar* dest, int32_t destCapacity,
147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                   int32_t options,
148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                   UParseError* parseError,
149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                   UErrorCode* status);
150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Convenience function that implements the IDNToUnicode operation as defined in the IDNA draft.
153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This operation is done on complete domain names, e.g: "www.example.com".
154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <b>Note:</b> IDNA draft specifies that a conformant application should divide a domain name
156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * into separate labels, decide whether to apply allowUnassigned and useSTD3ASCIIRules on each,
157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and then convert. This function does not offer that level of granularity. The options once
158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * set will apply to all labels in the domain name
159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param src               Input Unicode IDN.
161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param srcLength         Number of UChars in src, or -1 if NUL-terminated.
162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param dest Output       ASCII array.
163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param destCapacity      Size of dest.
164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param options           A bit set of options:
165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  - idnaref_UNASSIGNED        Unassigned values can be converted to ASCII for query operations
167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          If TRUE unassigned values are treated as normal Unicode code points.
168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          If FALSE the operation fails with U_UNASSIGNED_CODE_POINT_FOUND error code.
169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  - idnaref_USE_STD3_RULES    Use STD3 ASCII rules for host name syntax restrictions
170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          If TRUE and the input does not statisfy STD3 rules, the operation
171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          will fail with U_IDNA_STD3_ASCII_RULES_ERROR
172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param parseError        Pointer to UParseError struct to recieve information on position
174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          of error if an error is encountered. Can be NULL.
175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status            ICU in/out error code parameter.
176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          U_INVALID_CHAR_FOUND if src contains
177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          unmatched single surrogates.
178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          U_INDEX_OUTOFBOUNDS_ERROR if src contains
179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          too many code points.
180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          U_BUFFER_OVERFLOW_ERROR if destCapacity is not enough
181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return                  Number of ASCII characters converted.
182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CFUNC int32_t U_EXPORT2
184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruidnaref_IDNToUnicode(  const UChar* src, int32_t srcLength,
185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                     UChar* dest, int32_t destCapacity,
186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                     int32_t options,
187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                     UParseError* parseError,
188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                     UErrorCode* status);
189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/**
191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Compare two strings for IDNs for equivalence.
192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This function splits the domain names into labels and compares them.
193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * According to IDN draft, whenever two labels are compared, they are
194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * considered equal if and only if their ASCII forms (obtained by
195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * applying toASCII) match using an case-insensitive ASCII comparison.
196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Two domain names are considered a match if and only if all labels
197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * match regardless of whether label separators match.
198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param s1                First source string.
200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param length1           Length of first source string, or -1 if NUL-terminated.
201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param s2                Second source string.
203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param length2           Length of second source string, or -1 if NUL-terminated.
204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param options           A bit set of options:
205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  - idnaref_UNASSIGNED        Unassigned values can be converted to ASCII for query operations
207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          If TRUE unassigned values are treated as normal Unicode code points.
208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          If FALSE the operation fails with U_UNASSIGNED_CODE_POINT_FOUND error code.
209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *  - idnaref_USE_STD3_RULES    Use STD3 ASCII rules for host name syntax restrictions
210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          If TRUE and the input does not statisfy STD3 rules, the operation
211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          will fail with U_IDNA_STD3_ASCII_RULES_ERROR
212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *
213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status            ICU error code in/out parameter.
214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru *                          Must fulfill U_SUCCESS before the function call.
215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return <0 or 0 or >0 as usual for string comparisons
216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */
217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CFUNC int32_t U_EXPORT2
218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruidnaref_compare(  const UChar *s1, int32_t length1,
219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                const UChar *s2, int32_t length2,
220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                int32_t options,
221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru                UErrorCode* status);
222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif /* #if !UCONFIG_NO_IDNA */
224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru
225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif
226