ICU 69.1  69.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 {
57 #ifndef U_HIDE_DEPRECATED_API
66 #endif /* U_HIDE_DEPRECATED_API */
119 };
120 
125 struct UIDNA;
126 typedef struct UIDNA UIDNA;
145 U_CAPI UIDNA * U_EXPORT2
146 uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode);
147 
153 U_CAPI void U_EXPORT2
155 
156 #if U_SHOW_CPLUSPLUS_API
157 
158 U_NAMESPACE_BEGIN
159 
170 
171 U_NAMESPACE_END
172 
173 #endif
174 
185 typedef struct UIDNAInfo {
187  int16_t size;
200  uint32_t errors;
201  int32_t reservedI2;
202  int32_t reservedI3;
204 
209 #define UIDNA_INFO_INITIALIZER { \
210  (int16_t)sizeof(UIDNAInfo), \
211  false, false, \
212  0, 0, 0 }
213 
237 U_CAPI int32_t U_EXPORT2
239  const UChar *label, int32_t length,
240  UChar *dest, int32_t capacity,
241  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
242 
264 U_CAPI int32_t U_EXPORT2
266  const UChar *label, int32_t length,
267  UChar *dest, int32_t capacity,
268  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
269 
293 U_CAPI int32_t U_EXPORT2
295  const UChar *name, int32_t length,
296  UChar *dest, int32_t capacity,
297  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
298 
320 U_CAPI int32_t U_EXPORT2
322  const UChar *name, int32_t length,
323  UChar *dest, int32_t capacity,
324  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
325 
326 /* UTF-8 versions of the processing methods --------------------------------- */
327 
345 U_CAPI int32_t U_EXPORT2
347  const char *label, int32_t length,
348  char *dest, int32_t capacity,
349  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
350 
368 U_CAPI int32_t U_EXPORT2
370  const char *label, int32_t length,
371  char *dest, int32_t capacity,
372  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
373 
391 U_CAPI int32_t U_EXPORT2
393  const char *name, int32_t length,
394  char *dest, int32_t capacity,
395  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
396 
414 U_CAPI int32_t U_EXPORT2
416  const char *name, int32_t length,
417  char *dest, int32_t capacity,
418  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
419 
420 /*
421  * IDNA error bit set values.
422  * When a domain name or label fails a processing step or does not meet the
423  * validity criteria, then one or more of these error bits are set.
424  */
425 enum {
514 };
515 
516 #ifndef U_HIDE_DEPRECATED_API
517 
518 /* IDNA2003 API ------------------------------------------------------------- */
519 
579 U_DEPRECATED int32_t U_EXPORT2
580 uidna_toASCII(const UChar* src, int32_t srcLength,
581  UChar* dest, int32_t destCapacity,
582  int32_t options,
583  UParseError* parseError,
584  UErrorCode* status);
585 
586 
627 U_DEPRECATED int32_t U_EXPORT2
628 uidna_toUnicode(const UChar* src, int32_t srcLength,
629  UChar* dest, int32_t destCapacity,
630  int32_t options,
631  UParseError* parseError,
632  UErrorCode* status);
633 
634 
678 U_DEPRECATED int32_t U_EXPORT2
679 uidna_IDNToASCII( const UChar* src, int32_t srcLength,
680  UChar* dest, int32_t destCapacity,
681  int32_t options,
682  UParseError* parseError,
683  UErrorCode* status);
684 
725 U_DEPRECATED int32_t U_EXPORT2
726 uidna_IDNToUnicode( const UChar* src, int32_t srcLength,
727  UChar* dest, int32_t destCapacity,
728  int32_t options,
729  UParseError* parseError,
730  UErrorCode* status);
731 
766 U_DEPRECATED int32_t U_EXPORT2
767 uidna_compare( const UChar *s1, int32_t length1,
768  const UChar *s2, int32_t length2,
769  int32_t options,
770  UErrorCode* status);
771 
772 #endif /* U_HIDE_DEPRECATED_API */
773 
774 #endif /* #if !UCONFIG_NO_IDNA */
775 
776 #endif
"Smart pointer" class, closes a UIDNA via uidna_close().
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:550
C API: Parse Error Information.
Output container for IDNA processing errors.
Definition: uidna.h:185
int16_t size
sizeof(UIDNAInfo)
Definition: uidna.h:187
int32_t reservedI3
Reserved field, do not use.
Definition: uidna.h:202
uint32_t errors
Bit set indicating IDNA processing errors.
Definition: uidna.h:200
UBool isTransitionalDifferent
Set to true if transitional and nontransitional processing produce different results.
Definition: uidna.h:193
UBool reservedB3
Reserved field, do not use.
Definition: uidna.h:194
int32_t reservedI2
Reserved field, do not use.
Definition: uidna.h:201
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:58
@ UIDNA_ERROR_CONTEXTO_DIGITS
A label does not meet the IDNA CONTEXTO requirements for digits.
Definition: uidna.h:513
@ UIDNA_ERROR_TRAILING_HYPHEN
A label ends with a hyphen-minus ('-').
Definition: uidna.h:454
@ UIDNA_ERROR_LEADING_COMBINING_MARK
A label starts with a combining mark.
Definition: uidna.h:464
@ UIDNA_ERROR_LABEL_TOO_LONG
A domain name label is longer than 63 bytes.
Definition: uidna.h:437
@ UIDNA_ERROR_CONTEXTJ
A label does not meet the IDNA CONTEXTJ requirements.
Definition: uidna.h:500
@ UIDNA_ERROR_DISALLOWED
A label or domain name contains disallowed characters.
Definition: uidna.h:469
@ UIDNA_ERROR_LABEL_HAS_DOT
A label contains a dot=full stop.
Definition: uidna.h:481
@ UIDNA_ERROR_BIDI
A label does not meet the IDNA BiDi requirements (for right-to-left characters).
Definition: uidna.h:495
@ UIDNA_ERROR_HYPHEN_3_4
A label contains hyphen-minus ('-') in the third and fourth positions.
Definition: uidna.h:459
@ UIDNA_ERROR_PUNYCODE
A label starts with "xn--" but does not contain valid Punycode.
Definition: uidna.h:475
@ UIDNA_ERROR_DOMAIN_NAME_TOO_LONG
A domain name is longer than 255 bytes in its storage form.
Definition: uidna.h:444
@ UIDNA_ERROR_LEADING_HYPHEN
A label starts with a hyphen-minus ('-').
Definition: uidna.h:449
@ UIDNA_ERROR_CONTEXTO_PUNCTUATION
A label does not meet the IDNA CONTEXTO requirements for punctuation characters.
Definition: uidna.h:507
@ UIDNA_ERROR_EMPTY_LABEL
A non-final domain name label (or the whole domain name) is empty.
Definition: uidna.h:430
@ UIDNA_ERROR_INVALID_ACE_LABEL
An ACE label does not contain a valid label string.
Definition: uidna.h:490
U_CAPI UIDNA * uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode)
Returns a UIDNA instance which implements UTS #46.
struct UIDNA UIDNA
C typedef for struct UIDNA.
Definition: uidna.h:126
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.
@ UIDNA_CHECK_CONTEXTJ
IDNA option to check for whether the input conforms to the CONTEXTJ rules.
Definition: uidna.h:90
@ UIDNA_NONTRANSITIONAL_TO_ASCII
IDNA option for nontransitional processing in ToASCII().
Definition: uidna.h:99
@ UIDNA_ALLOW_UNASSIGNED
Option to allow unassigned code points in domain names and labels.
Definition: uidna.h:65
@ UIDNA_CHECK_CONTEXTO
IDNA option to check for whether the input conforms to the CONTEXTO rules.
Definition: uidna.h:118
@ UIDNA_CHECK_BIDI
IDNA option to check for whether the input conforms to the BiDi rules.
Definition: uidna.h:82
@ UIDNA_USE_STD3_RULES
Option to check whether the input conforms to the STD3 ASCII rules, for example the restriction of la...
Definition: uidna.h:74
@ UIDNA_DEFAULT
Default options value: None of the other options are set.
Definition: uidna.h:56
@ UIDNA_NONTRANSITIONAL_TO_UNICODE
IDNA option for nontransitional processing in ToUnicode().
Definition: uidna.h:108
U_CAPI void uidna_close(UIDNA *idna)
Closes a UIDNA instance.
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.
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.
struct UIDNAInfo UIDNAInfo
Output container for IDNA processing errors.
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.
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.
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.
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_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.
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.
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.
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.
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.
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.
#define U_DEPRECATED
This is used to declare a function as a deprecated public ICU C API
Definition: umachine.h:116
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition: umachine.h:110
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:418
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415