ICU 58.2 58.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

uidna.h
Go to the documentation of this file.
1 // Copyright (C) 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: US-ASCII
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 {
52 UIDNA_DEFAULT=0,
53 #ifndef U_HIDE_DEPRECATED_API
54
61 UIDNA_ALLOW_UNASSIGNED=1,
62 #endif /* U_HIDE_DEPRECATED_API */
63
70 UIDNA_USE_STD3_RULES=2,
78 UIDNA_CHECK_BIDI=4,
86 UIDNA_CHECK_CONTEXTJ=8,
95 UIDNA_NONTRANSITIONAL_TO_ASCII=0x10,
104 UIDNA_NONTRANSITIONAL_TO_UNICODE=0x20,
114 UIDNA_CHECK_CONTEXTO=0x40
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
154 U_NAMESPACE_BEGIN
155
165 U_DEFINE_LOCAL_OPEN_POINTER(LocalUIDNAPointer, UIDNA, uidna_close);
166
167 U_NAMESPACE_END
168
169 #endif
170
181 typedef struct UIDNAInfo {
183 int16_t size;
189 UBool isTransitionalDifferent;
190 UBool reservedB3;
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 {
426 UIDNA_ERROR_EMPTY_LABEL=1,
433 UIDNA_ERROR_LABEL_TOO_LONG=2,
440 UIDNA_ERROR_DOMAIN_NAME_TOO_LONG=4,
445 UIDNA_ERROR_LEADING_HYPHEN=8,
450 UIDNA_ERROR_TRAILING_HYPHEN=0x10,
455 UIDNA_ERROR_HYPHEN_3_4=0x20,
460 UIDNA_ERROR_LEADING_COMBINING_MARK=0x40,
465 UIDNA_ERROR_DISALLOWED=0x80,
471 UIDNA_ERROR_PUNYCODE=0x100,
477 UIDNA_ERROR_LABEL_HAS_DOT=0x200,
486 UIDNA_ERROR_INVALID_ACE_LABEL=0x400,
491 UIDNA_ERROR_BIDI=0x800,
496 UIDNA_ERROR_CONTEXTJ=0x1000,
503 UIDNA_ERROR_CONTEXTO_PUNCTUATION=0x2000,
509 UIDNA_ERROR_CONTEXTO_DIGITS=0x4000
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
uidna_IDNToUnicode
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...
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:70
UIDNA_ERROR_HYPHEN_3_4
A label contains hyphen-minus (&#39;-&#39;) in the third and fourth positions.
Definition: uidna.h:455
UIDNA_ERROR_BIDI
A label does not meet the IDNA BiDi requirements (for right-to-left characters).
Definition: uidna.h:491
UIDNA_ERROR_CONTEXTJ
A label does not meet the IDNA CONTEXTJ requirements.
Definition: uidna.h:496
UIDNA_ERROR_LEADING_HYPHEN
A label starts with a hyphen-minus (&#39;-&#39;).
Definition: uidna.h:445
UIDNA_ERROR_LABEL_HAS_DOT
A label contains a dot=full stop.
Definition: uidna.h:477
UIDNA_ERROR_DOMAIN_NAME_TOO_LONG
A domain name is longer than 255 bytes in its storage form.
Definition: uidna.h:440
UIDNA_NONTRANSITIONAL_TO_UNICODE
IDNA option for nontransitional processing in ToUnicode().
Definition: uidna.h:104
UIDNA_CHECK_CONTEXTJ
IDNA option to check for whether the input conforms to the CONTEXTJ rules.
Definition: uidna.h:86
UIDNA_CHECK_CONTEXTO
IDNA option to check for whether the input conforms to the CONTEXTO rules.
Definition: uidna.h:114
UIDNAInfo
struct UIDNAInfo UIDNAInfo
Output container for IDNA processing errors.
UIDNA_ERROR_CONTEXTO_PUNCTUATION
A label does not meet the IDNA CONTEXTO requirements for punctuation characters.
Definition: uidna.h:503
uidna_labelToUnicodeUTF8
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.
UIDNAInfo
Output container for IDNA processing errors.
Definition: uidna.h:181
UIDNA_ERROR_EMPTY_LABEL
A non-final domain name label (or the whole domain name) is empty.
Definition: uidna.h:426
U_DEPRECATED
#define U_DEPRECATED
This is used to declare a function as a deprecated public ICU C API.
Definition: umachine.h:138
UIDNA_ERROR_DISALLOWED
A label or domain name contains disallowed characters.
Definition: uidna.h:465
UIDNA_ERROR_TRAILING_HYPHEN
A label ends with a hyphen-minus (&#39;-&#39;).
Definition: uidna.h:450
UIDNAInfo::size
int16_t size
sizeof(UIDNAInfo)
Definition: uidna.h:183
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
uidna_toUnicode
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_DEFINE_LOCAL_OPEN_POINTER
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
Definition: localpointer.h:530
UIDNA_NONTRANSITIONAL_TO_ASCII
IDNA option for nontransitional processing in ToASCII().
Definition: uidna.h:95
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
UIDNAInfo::reservedB3
UBool reservedB3
Reserved field, do not use.
Definition: uidna.h:190
UIDNA_CHECK_BIDI
IDNA option to check for whether the input conforms to the BiDi rules.
Definition: uidna.h:78
UIDNAInfo::isTransitionalDifferent
UBool isTransitionalDifferent
Set to TRUE if transitional and nontransitional processing produce different results.
Definition: uidna.h:189
UIDNA_ALLOW_UNASSIGNED
Option to allow unassigned code points in domain names and labels.
Definition: uidna.h:61
UIDNA_ERROR_INVALID_ACE_LABEL
An ACE label does not contain a valid label string.
Definition: uidna.h:486
UIDNAInfo::reservedI3
int32_t reservedI3
Reserved field, do not use.
Definition: uidna.h:198
UChar
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition: umachine.h:337
UIDNA
struct UIDNA UIDNA
C typedef for struct UIDNA.
Definition: uidna.h:122
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
parseerr.h
C API: Parse Error Information.
UIDNAInfo::errors
uint32_t errors
Bit set indicating IDNA processing errors.
Definition: uidna.h:196
uidna_toASCII
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.
uidna_close
void uidna_close(UIDNA *idna)
Closes a UIDNA instance.
uidna_openUTS46
UIDNA * uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode)
Returns a UIDNA instance which implements UTS #46.
uidna_compare
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.
UIDNA_ERROR_CONTEXTO_DIGITS
A label does not meet the IDNA CONTEXTO requirements for digits.
Definition: uidna.h:509
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
UIDNA_ERROR_LABEL_TOO_LONG
A domain name label is longer than 63 bytes.
Definition: uidna.h:433
uidna_nameToUnicode
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.
uidna_nameToUnicodeUTF8
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.
uidna_labelToASCII
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.
uidna_labelToASCII_UTF8
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.
uidna_nameToASCII_UTF8
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.
uidna_labelToUnicode
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.
UParseError
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:58
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UIDNA_ERROR_LEADING_COMBINING_MARK
A label starts with a combining mark.
Definition: uidna.h:460
uidna_IDNToASCII
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_DEFAULT
Default options value: None of the other options are set.
Definition: uidna.h:52
UIDNAInfo::reservedI2
int32_t reservedI2
Reserved field, do not use.
Definition: uidna.h:197
uidna_nameToASCII
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.
UIDNA_ERROR_PUNYCODE
A label starts with "xn--" but does not contain valid Punycode.
Definition: uidna.h:471
LocalUIDNAPointer
"Smart pointer" class, closes a UIDNA via uidna_close().
U_STABLE
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:134
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:259