ICU 76.1  76.1
uidna.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4  *******************************************************************************
5  *
6  * Copyright (C) 2003-2014, International Business Machines
7  * Corporation and others. All Rights Reserved.
8  *
9  *******************************************************************************
10  * file name: uidna.h
11  * encoding: UTF-8
12  * tab size: 8 (not used)
13  * indentation:4
14  *
15  * created on: 2003feb1
16  * created by: Ram Viswanadha
17  */
18 
19 #ifndef __UIDNA_H__
20 #define __UIDNA_H__
21 
22 #include "unicode/utypes.h"
23 
24 #if !UCONFIG_NO_IDNA
25 
26 #include <stdbool.h>
27 #include "unicode/parseerr.h"
28 
29 #if U_SHOW_CPLUSPLUS_API
30 #include "unicode/localpointer.h"
31 #endif // U_SHOW_CPLUSPLUS_API
32 
47 /*
48  * IDNA option bit set values.
49  */
50 enum {
65 #ifndef U_HIDE_DEPRECATED_API
66 
74 #endif /* U_HIDE_DEPRECATED_API */
75 
135 };
136 
141 struct UIDNA;
142 typedef struct UIDNA UIDNA;
163 U_CAPI UIDNA * U_EXPORT2
164 uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode);
165 
171 U_CAPI void U_EXPORT2
172 uidna_close(UIDNA *idna);
173 
174 #if U_SHOW_CPLUSPLUS_API
175 
176 U_NAMESPACE_BEGIN
177 
188 
189 U_NAMESPACE_END
190 
191 #endif
192 
203 typedef struct UIDNAInfo {
205  int16_t size;
218  uint32_t errors;
219  int32_t reservedI2;
220  int32_t reservedI3;
221 } UIDNAInfo;
222 
227 #define UIDNA_INFO_INITIALIZER { \
228  (int16_t)sizeof(UIDNAInfo), \
229  false, false, \
230  0, 0, 0 }
231 
255 U_CAPI int32_t U_EXPORT2
256 uidna_labelToASCII(const UIDNA *idna,
257  const UChar *label, int32_t length,
258  UChar *dest, int32_t capacity,
259  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
260 
282 U_CAPI int32_t U_EXPORT2
283 uidna_labelToUnicode(const UIDNA *idna,
284  const UChar *label, int32_t length,
285  UChar *dest, int32_t capacity,
286  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
287 
311 U_CAPI int32_t U_EXPORT2
312 uidna_nameToASCII(const UIDNA *idna,
313  const UChar *name, int32_t length,
314  UChar *dest, int32_t capacity,
315  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
316 
338 U_CAPI int32_t U_EXPORT2
339 uidna_nameToUnicode(const UIDNA *idna,
340  const UChar *name, int32_t length,
341  UChar *dest, int32_t capacity,
342  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
343 
344 /* UTF-8 versions of the processing methods --------------------------------- */
345 
363 U_CAPI int32_t U_EXPORT2
364 uidna_labelToASCII_UTF8(const UIDNA *idna,
365  const char *label, int32_t length,
366  char *dest, int32_t capacity,
367  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
368 
386 U_CAPI int32_t U_EXPORT2
387 uidna_labelToUnicodeUTF8(const UIDNA *idna,
388  const char *label, int32_t length,
389  char *dest, int32_t capacity,
390  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
391 
409 U_CAPI int32_t U_EXPORT2
410 uidna_nameToASCII_UTF8(const UIDNA *idna,
411  const char *name, int32_t length,
412  char *dest, int32_t capacity,
413  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
414 
432 U_CAPI int32_t U_EXPORT2
433 uidna_nameToUnicodeUTF8(const UIDNA *idna,
434  const char *name, int32_t length,
435  char *dest, int32_t capacity,
436  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
437 
438 /*
439  * IDNA error bit set values.
440  * When a domain name or label fails a processing step or does not meet the
441  * validity criteria, then one or more of these error bits are set.
442  */
443 enum {
532 };
533 
534 #ifndef U_HIDE_DEPRECATED_API
535 
536 /* IDNA2003 API ------------------------------------------------------------- */
537 
597 U_DEPRECATED int32_t U_EXPORT2
598 uidna_toASCII(const UChar* src, int32_t srcLength,
599  UChar* dest, int32_t destCapacity,
600  int32_t options,
601  UParseError* parseError,
602  UErrorCode* status);
603 
604 
645 U_DEPRECATED int32_t U_EXPORT2
646 uidna_toUnicode(const UChar* src, int32_t srcLength,
647  UChar* dest, int32_t destCapacity,
648  int32_t options,
649  UParseError* parseError,
650  UErrorCode* status);
651 
652 
696 U_DEPRECATED int32_t U_EXPORT2
697 uidna_IDNToASCII( const UChar* src, int32_t srcLength,
698  UChar* dest, int32_t destCapacity,
699  int32_t options,
700  UParseError* parseError,
701  UErrorCode* status);
702 
743 U_DEPRECATED int32_t U_EXPORT2
744 uidna_IDNToUnicode( const UChar* src, int32_t srcLength,
745  UChar* dest, int32_t destCapacity,
746  int32_t options,
747  UParseError* parseError,
748  UErrorCode* status);
749 
784 U_DEPRECATED int32_t U_EXPORT2
785 uidna_compare( const UChar *s1, int32_t length1,
786  const UChar *s2, int32_t length2,
787  int32_t options,
788  UErrorCode* status);
789 
790 #endif /* U_HIDE_DEPRECATED_API */
791 
792 #endif /* #if !UCONFIG_NO_IDNA */
793 
794 #endif
U_CAPI int32_t uidna_labelToASCII(const UIDNA *idna, const UChar *label, int32_t length, UChar *dest, int32_t capacity, UIDNAInfo *pInfo, UErrorCode *pErrorCode)
Converts a single domain name label into its ASCII form for DNS lookup.
int32_t uidna_IDNToUnicode(const UChar *src, int32_t srcLength, UChar *dest, int32_t destCapacity, int32_t options, UParseError *parseError, UErrorCode *status)
IDNA2003: Convenience function that implements the IDNToUnicode operation as defined in the IDNA RFC...
Option to check whether the input conforms to the STD3 ASCII rules, for example the restriction of la...
Definition: uidna.h:82
U_CAPI UIDNA * uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode)
Returns a UIDNA instance which implements UTS #46.
A label contains hyphen-minus (&#39;-&#39;) in the third and fourth positions.
Definition: uidna.h:477
A label does not meet the IDNA BiDi requirements (for right-to-left characters).
Definition: uidna.h:513
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:110
A label does not meet the IDNA CONTEXTJ requirements.
Definition: uidna.h:518
A label starts with a hyphen-minus (&#39;-&#39;).
Definition: uidna.h:467
U_CAPI int32_t uidna_labelToUnicodeUTF8(const UIDNA *idna, const char *label, int32_t length, char *dest, int32_t capacity, UIDNAInfo *pInfo, UErrorCode *pErrorCode)
Converts a single domain name label into its Unicode form for human-readable display.
A label contains a dot=full stop.
Definition: uidna.h:499
A domain name is longer than 255 bytes in its storage form.
Definition: uidna.h:462
U_CAPI int32_t uidna_nameToUnicodeUTF8(const UIDNA *idna, const char *name, int32_t length, char *dest, int32_t capacity, UIDNAInfo *pInfo, UErrorCode *pErrorCode)
Converts a whole domain name into its Unicode form for human-readable display.
IDNA option for nontransitional processing in ToUnicode().
Definition: uidna.h:124
IDNA option to check for whether the input conforms to the CONTEXTJ rules.
Definition: uidna.h:98
IDNA option to check for whether the input conforms to the CONTEXTO rules.
Definition: uidna.h:134
struct UIDNAInfo UIDNAInfo
Output container for IDNA processing errors.
A label does not meet the IDNA CONTEXTO requirements for punctuation characters.
Definition: uidna.h:525
Output container for IDNA processing errors.
Definition: uidna.h:203
A non-final domain name label (or the whole domain name) is empty.
Definition: uidna.h:448
#define U_DEPRECATED
This is used to declare a function as a deprecated public ICU C API.
Definition: umachine.h:116
A label or domain name contains disallowed characters.
Definition: uidna.h:487
A label ends with a hyphen-minus (&#39;-&#39;).
Definition: uidna.h:472
int16_t size
sizeof(UIDNAInfo)
Definition: uidna.h:205
int32_t uidna_toUnicode(const UChar *src, int32_t srcLength, UChar *dest, int32_t destCapacity, int32_t options, UParseError *parseError, UErrorCode *status)
IDNA2003: This function implements the ToUnicode operation as defined in the IDNA RFC...
U_CAPI int32_t uidna_labelToUnicode(const UIDNA *idna, const UChar *label, int32_t length, UChar *dest, int32_t capacity, UIDNAInfo *pInfo, UErrorCode *pErrorCode)
Converts a single domain name label into its Unicode form for human-readable display.
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:550
IDNA option for nontransitional processing in ToASCII().
Definition: uidna.h:111
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
UBool reservedB3
Reserved field, do not use.
Definition: uidna.h:212
IDNA option to check for whether the input conforms to the BiDi rules.
Definition: uidna.h:90
UBool isTransitionalDifferent
Set to true if transitional and nontransitional processing produce different results.
Definition: uidna.h:211
Option to allow unassigned code points in domain names and labels.
Definition: uidna.h:73
An ACE label does not contain a valid label string.
Definition: uidna.h:508
int32_t reservedI3
Reserved field, do not use.
Definition: uidna.h:220
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:378
struct UIDNA UIDNA
C typedef for struct UIDNA.
Definition: uidna.h:142
C API: Parse Error Information.
uint32_t errors
Bit set indicating IDNA processing errors.
Definition: uidna.h:218
int32_t uidna_toASCII(const UChar *src, int32_t srcLength, UChar *dest, int32_t destCapacity, int32_t options, UParseError *parseError, UErrorCode *status)
IDNA2003: This function implements the ToASCII operation as defined in the IDNA RFC.
int32_t uidna_compare(const UChar *s1, int32_t length1, const UChar *s2, int32_t length2, int32_t options, UErrorCode *status)
IDNA2003: Compare two IDN strings for equivalence.
A label does not meet the IDNA CONTEXTO requirements for digits.
Definition: uidna.h:531
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:430
A domain name label is longer than 63 bytes.
Definition: uidna.h:455
U_CAPI int32_t uidna_nameToASCII(const UIDNA *idna, const UChar *name, int32_t length, UChar *dest, int32_t capacity, UIDNAInfo *pInfo, UErrorCode *pErrorCode)
Converts a whole domain name into its ASCII form for DNS lookup.
U_CAPI int32_t uidna_labelToASCII_UTF8(const UIDNA *idna, const char *label, int32_t length, char *dest, int32_t capacity, UIDNAInfo *pInfo, UErrorCode *pErrorCode)
Converts a single domain name label into its ASCII form for DNS lookup.
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:58
Basic definitions for ICU, for both C and C++ APIs.
U_CAPI int32_t uidna_nameToUnicode(const UIDNA *idna, const UChar *name, int32_t length, UChar *dest, int32_t capacity, UIDNAInfo *pInfo, UErrorCode *pErrorCode)
Converts a whole domain name into its Unicode form for human-readable display.
A label starts with a combining mark.
Definition: uidna.h:482
int32_t uidna_IDNToASCII(const UChar *src, int32_t srcLength, UChar *dest, int32_t destCapacity, int32_t options, UParseError *parseError, UErrorCode *status)
IDNA2003: Convenience function that implements the IDNToASCII operation as defined in the IDNA RFC...
U_CAPI int32_t uidna_nameToASCII_UTF8(const UIDNA *idna, const char *name, int32_t length, char *dest, int32_t capacity, UIDNAInfo *pInfo, UErrorCode *pErrorCode)
Converts a whole domain name into its ASCII form for DNS lookup.
Default options value: UTS #46 nontransitional processing.
Definition: uidna.h:64
int32_t reservedI2
Reserved field, do not use.
Definition: uidna.h:219
A label starts with "xn--" but does not contain valid Punycode.
Definition: uidna.h:493
"Smart pointer" class, closes a UIDNA via uidna_close().
U_CAPI void uidna_close(UIDNA *idna)
Closes a UIDNA instance.
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:247