ICU 63.1  63.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 "unicode/localpointer.h"
27 #include "unicode/parseerr.h"
28 
43 /*
44  * IDNA option bit set values.
45  */
46 enum {
53 #ifndef U_HIDE_DEPRECATED_API
54 
62 #endif /* U_HIDE_DEPRECATED_API */
63 
115 };
116 
121 struct UIDNA;
122 typedef struct UIDNA UIDNA;
141 U_STABLE UIDNA * U_EXPORT2
142 uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode);
143 
149 U_STABLE void U_EXPORT2
150 uidna_close(UIDNA *idna);
151 
152 #if U_SHOW_CPLUSPLUS_API
153 
155 
166 
168 
169 #endif
170 
181 typedef struct UIDNAInfo {
183  int16_t size;
196  uint32_t errors;
197  int32_t reservedI2;
198  int32_t reservedI3;
199 } UIDNAInfo;
200 
205 #define UIDNA_INFO_INITIALIZER { \
206  (int16_t)sizeof(UIDNAInfo), \
207  FALSE, FALSE, \
208  0, 0, 0 }
209 
233 U_STABLE int32_t U_EXPORT2
234 uidna_labelToASCII(const UIDNA *idna,
235  const UChar *label, int32_t length,
236  UChar *dest, int32_t capacity,
237  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
238 
260 U_STABLE int32_t U_EXPORT2
261 uidna_labelToUnicode(const UIDNA *idna,
262  const UChar *label, int32_t length,
263  UChar *dest, int32_t capacity,
264  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
265 
289 U_STABLE int32_t U_EXPORT2
290 uidna_nameToASCII(const UIDNA *idna,
291  const UChar *name, int32_t length,
292  UChar *dest, int32_t capacity,
293  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
294 
316 U_STABLE int32_t U_EXPORT2
317 uidna_nameToUnicode(const UIDNA *idna,
318  const UChar *name, int32_t length,
319  UChar *dest, int32_t capacity,
320  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
321 
322 /* UTF-8 versions of the processing methods --------------------------------- */
323 
341 U_STABLE int32_t U_EXPORT2
342 uidna_labelToASCII_UTF8(const UIDNA *idna,
343  const char *label, int32_t length,
344  char *dest, int32_t capacity,
345  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
346 
364 U_STABLE int32_t U_EXPORT2
365 uidna_labelToUnicodeUTF8(const UIDNA *idna,
366  const char *label, int32_t length,
367  char *dest, int32_t capacity,
368  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
369 
387 U_STABLE int32_t U_EXPORT2
388 uidna_nameToASCII_UTF8(const UIDNA *idna,
389  const char *name, int32_t length,
390  char *dest, int32_t capacity,
391  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
392 
410 U_STABLE int32_t U_EXPORT2
411 uidna_nameToUnicodeUTF8(const UIDNA *idna,
412  const char *name, int32_t length,
413  char *dest, int32_t capacity,
414  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
415 
416 /*
417  * IDNA error bit set values.
418  * When a domain name or label fails a processing step or does not meet the
419  * validity criteria, then one or more of these error bits are set.
420  */
421 enum {
510 };
511 
512 #ifndef U_HIDE_DEPRECATED_API
513 
514 /* IDNA2003 API ------------------------------------------------------------- */
515 
575 U_DEPRECATED int32_t U_EXPORT2
576 uidna_toASCII(const UChar* src, int32_t srcLength,
577  UChar* dest, int32_t destCapacity,
578  int32_t options,
579  UParseError* parseError,
580  UErrorCode* status);
581 
582 
623 U_DEPRECATED int32_t U_EXPORT2
624 uidna_toUnicode(const UChar* src, int32_t srcLength,
625  UChar* dest, int32_t destCapacity,
626  int32_t options,
627  UParseError* parseError,
628  UErrorCode* status);
629 
630 
674 U_DEPRECATED int32_t U_EXPORT2
675 uidna_IDNToASCII( const UChar* src, int32_t srcLength,
676  UChar* dest, int32_t destCapacity,
677  int32_t options,
678  UParseError* parseError,
679  UErrorCode* status);
680 
721 U_DEPRECATED int32_t U_EXPORT2
722 uidna_IDNToUnicode( const UChar* src, int32_t srcLength,
723  UChar* dest, int32_t destCapacity,
724  int32_t options,
725  UParseError* parseError,
726  UErrorCode* status);
727 
762 U_DEPRECATED int32_t U_EXPORT2
763 uidna_compare( const UChar *s1, int32_t length1,
764  const UChar *s2, int32_t length2,
765  int32_t options,
766  UErrorCode* status);
767 
768 #endif /* U_HIDE_DEPRECATED_API */
769 
770 #endif /* #if !UCONFIG_NO_IDNA */
771 
772 #endif
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:70
A label contains hyphen-minus ('-') in the third and fourth positions.
Definition: uidna.h:455
A label does not meet the IDNA BiDi requirements (for right-to-left characters).
Definition: uidna.h:491
A label does not meet the IDNA CONTEXTJ requirements.
Definition: uidna.h:496
A label starts with a hyphen-minus ('-').
Definition: uidna.h:445
A label contains a dot=full stop.
Definition: uidna.h:477
A domain name is longer than 255 bytes in its storage form.
Definition: uidna.h:440
IDNA option for nontransitional processing in ToUnicode().
Definition: uidna.h:104
IDNA option to check for whether the input conforms to the CONTEXTJ rules.
Definition: uidna.h:86
IDNA option to check for whether the input conforms to the CONTEXTO rules.
Definition: uidna.h:114
struct UIDNAInfo UIDNAInfo
Output container for IDNA processing errors.
A label does not meet the IDNA CONTEXTO requirements for punctuation characters.
Definition: uidna.h:503
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.
Output container for IDNA processing errors.
Definition: uidna.h:181
A non-final domain name label (or the whole domain name) is empty.
Definition: uidna.h:426
#define U_DEPRECATED
This is used to declare a function as a deprecated public ICU C API.
Definition: umachine.h:115
A label or domain name contains disallowed characters.
Definition: uidna.h:465
A label ends with a hyphen-minus ('-').
Definition: uidna.h:450
int16_t size
sizeof(UIDNAInfo)
Definition: uidna.h:183
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
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_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:487
IDNA option for nontransitional processing in ToASCII().
Definition: uidna.h:95
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
UBool reservedB3
Reserved field, do not use.
Definition: uidna.h:190
IDNA option to check for whether the input conforms to the BiDi rules.
Definition: uidna.h:78
UBool isTransitionalDifferent
Set to TRUE if transitional and nontransitional processing produce different results.
Definition: uidna.h:189
Option to allow unassigned code points in domain names and labels.
Definition: uidna.h:61
An ACE label does not contain a valid label string.
Definition: uidna.h:486
int32_t reservedI3
Reserved field, do not use.
Definition: uidna.h:198
uint16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:342
struct UIDNA UIDNA
C typedef for struct UIDNA.
Definition: uidna.h:122
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
C API: Parse Error Information.
uint32_t errors
Bit set indicating IDNA processing errors.
Definition: uidna.h:196
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.
void uidna_close(UIDNA *idna)
Closes a UIDNA instance.
UIDNA * uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode)
Returns a UIDNA instance which implements UTS #46.
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:509
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:401
A domain name label is longer than 63 bytes.
Definition: uidna.h:433
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_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_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_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.
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_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.
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.
A label starts with a combining mark.
Definition: uidna.h:460
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...
Default options value: None of the other options are set.
Definition: uidna.h:52
int32_t reservedI2
Reserved field, do not use.
Definition: uidna.h:197
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.
A label starts with "xn--" but does not contain valid Punycode.
Definition: uidna.h:471
"Smart pointer" class, closes a UIDNA via uidna_close().
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:111
int8_t UBool
The ICU boolean type.
Definition: umachine.h:225