ICU 56.1: uidna.h Source File

ICU 56.1 56.1

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

- File List
- Globals

uidna.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 *
4 * Copyright (C) 2003-2014, International Business Machines
5 * Corporation and others. All Rights Reserved.
6 *
7 *******************************************************************************
8 * file name: uidna.h
9 * encoding: US-ASCII
10 * tab size: 8 (not used)
11 * indentation:4
12 *
13 * created on: 2003feb1
14 * created by: Ram Viswanadha
15 */
16
17 #ifndef __UIDNA_H__
18 #define __UIDNA_H__
19
20 #include "unicode/utypes.h"
21
22 #if !UCONFIG_NO_IDNA
23
24 #include "unicode/localpointer.h"
25 #include "unicode/parseerr.h"
26
41 /*
42 * IDNA option bit set values.
43 */
44 enum {
50 UIDNA_DEFAULT=0,
51 #ifndef U_HIDE_DEPRECATED_API
52
59 UIDNA_ALLOW_UNASSIGNED=1,
60 #endif /* U_HIDE_DEPRECATED_API */
61
68 UIDNA_USE_STD3_RULES=2,
76 UIDNA_CHECK_BIDI=4,
84 UIDNA_CHECK_CONTEXTJ=8,
93 UIDNA_NONTRANSITIONAL_TO_ASCII=0x10,
102 UIDNA_NONTRANSITIONAL_TO_UNICODE=0x20,
112 UIDNA_CHECK_CONTEXTO=0x40
113 };
114
119 struct UIDNA;
120 typedef struct UIDNA UIDNA;
139 U_STABLE UIDNA * U_EXPORT2
140 uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode);
141
147 U_STABLE void U_EXPORT2
148 uidna_close(UIDNA *idna);
149
150 #if U_SHOW_CPLUSPLUS_API
151
152 U_NAMESPACE_BEGIN
153
163 U_DEFINE_LOCAL_OPEN_POINTER(LocalUIDNAPointer, UIDNA, uidna_close);
164
165 U_NAMESPACE_END
166
167 #endif
168
179 typedef struct UIDNAInfo {
181 int16_t size;
187 UBool isTransitionalDifferent;
188 UBool reservedB3;
194 uint32_t errors;
195 int32_t reservedI2;
196 int32_t reservedI3;
197 } UIDNAInfo;
198
203 #define UIDNA_INFO_INITIALIZER { \
204 (int16_t)sizeof(UIDNAInfo), \
205 FALSE, FALSE, \
206 0, 0, 0 }
207
231 U_STABLE int32_t U_EXPORT2
232 uidna_labelToASCII(const UIDNA *idna,
233 const UChar *label, int32_t length,
234 UChar *dest, int32_t capacity,
235 UIDNAInfo *pInfo, UErrorCode *pErrorCode);
236
258 U_STABLE int32_t U_EXPORT2
259 uidna_labelToUnicode(const UIDNA *idna,
260 const UChar *label, int32_t length,
261 UChar *dest, int32_t capacity,
262 UIDNAInfo *pInfo, UErrorCode *pErrorCode);
263
287 U_STABLE int32_t U_EXPORT2
288 uidna_nameToASCII(const UIDNA *idna,
289 const UChar *name, int32_t length,
290 UChar *dest, int32_t capacity,
291 UIDNAInfo *pInfo, UErrorCode *pErrorCode);
292
314 U_STABLE int32_t U_EXPORT2
315 uidna_nameToUnicode(const UIDNA *idna,
316 const UChar *name, int32_t length,
317 UChar *dest, int32_t capacity,
318 UIDNAInfo *pInfo, UErrorCode *pErrorCode);
319
320 /* UTF-8 versions of the processing methods --------------------------------- */
321
339 U_STABLE int32_t U_EXPORT2
340 uidna_labelToASCII_UTF8(const UIDNA *idna,
341 const char *label, int32_t length,
342 char *dest, int32_t capacity,
343 UIDNAInfo *pInfo, UErrorCode *pErrorCode);
344
362 U_STABLE int32_t U_EXPORT2
363 uidna_labelToUnicodeUTF8(const UIDNA *idna,
364 const char *label, int32_t length,
365 char *dest, int32_t capacity,
366 UIDNAInfo *pInfo, UErrorCode *pErrorCode);
367
385 U_STABLE int32_t U_EXPORT2
386 uidna_nameToASCII_UTF8(const UIDNA *idna,
387 const char *name, int32_t length,
388 char *dest, int32_t capacity,
389 UIDNAInfo *pInfo, UErrorCode *pErrorCode);
390
408 U_STABLE int32_t U_EXPORT2
409 uidna_nameToUnicodeUTF8(const UIDNA *idna,
410 const char *name, int32_t length,
411 char *dest, int32_t capacity,
412 UIDNAInfo *pInfo, UErrorCode *pErrorCode);
413
414 /*
415 * IDNA error bit set values.
416 * When a domain name or label fails a processing step or does not meet the
417 * validity criteria, then one or more of these error bits are set.
418 */
419 enum {
424 UIDNA_ERROR_EMPTY_LABEL=1,
431 UIDNA_ERROR_LABEL_TOO_LONG=2,
438 UIDNA_ERROR_DOMAIN_NAME_TOO_LONG=4,
443 UIDNA_ERROR_LEADING_HYPHEN=8,
448 UIDNA_ERROR_TRAILING_HYPHEN=0x10,
453 UIDNA_ERROR_HYPHEN_3_4=0x20,
458 UIDNA_ERROR_LEADING_COMBINING_MARK=0x40,
463 UIDNA_ERROR_DISALLOWED=0x80,
469 UIDNA_ERROR_PUNYCODE=0x100,
475 UIDNA_ERROR_LABEL_HAS_DOT=0x200,
484 UIDNA_ERROR_INVALID_ACE_LABEL=0x400,
489 UIDNA_ERROR_BIDI=0x800,
494 UIDNA_ERROR_CONTEXTJ=0x1000,
501 UIDNA_ERROR_CONTEXTO_PUNCTUATION=0x2000,
507 UIDNA_ERROR_CONTEXTO_DIGITS=0x4000
508 };
509
510 #ifndef U_HIDE_DEPRECATED_API
511
512 /* IDNA2003 API ------------------------------------------------------------- */
513
573 U_DEPRECATED int32_t U_EXPORT2
574 uidna_toASCII(const UChar* src, int32_t srcLength,
575 UChar* dest, int32_t destCapacity,
576 int32_t options,
577 UParseError* parseError,
578 UErrorCode* status);
579
580
621 U_DEPRECATED int32_t U_EXPORT2
622 uidna_toUnicode(const UChar* src, int32_t srcLength,
623 UChar* dest, int32_t destCapacity,
624 int32_t options,
625 UParseError* parseError,
626 UErrorCode* status);
627
628
672 U_DEPRECATED int32_t U_EXPORT2
673 uidna_IDNToASCII( const UChar* src, int32_t srcLength,
674 UChar* dest, int32_t destCapacity,
675 int32_t options,
676 UParseError* parseError,
677 UErrorCode* status);
678
719 U_DEPRECATED int32_t U_EXPORT2
720 uidna_IDNToUnicode( const UChar* src, int32_t srcLength,
721 UChar* dest, int32_t destCapacity,
722 int32_t options,
723 UParseError* parseError,
724 UErrorCode* status);
725
760 U_DEPRECATED int32_t U_EXPORT2
761 uidna_compare( const UChar *s1, int32_t length1,
762 const UChar *s2, int32_t length2,
763 int32_t options,
764 UErrorCode* status);
765
766 #endif /* U_HIDE_DEPRECATED_API */
767
768 #endif /* #if !UCONFIG_NO_IDNA */
769
770 #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:68
UIDNA_ERROR_HYPHEN_3_4
A label contains hyphen-minus ('-') in the third and fourth positions.
Definition: uidna.h:453
UIDNA_ERROR_BIDI
A label does not meet the IDNA BiDi requirements (for right-to-left characters).
Definition: uidna.h:489
UIDNA_ERROR_CONTEXTJ
A label does not meet the IDNA CONTEXTJ requirements.
Definition: uidna.h:494
UIDNA_ERROR_LEADING_HYPHEN
A label starts with a hyphen-minus ('-').
Definition: uidna.h:443
UIDNA_ERROR_LABEL_HAS_DOT
A label contains a dot=full stop.
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:438
UIDNA_NONTRANSITIONAL_TO_UNICODE
IDNA option for nontransitional processing in ToUnicode().
Definition: uidna.h:102
UIDNA_CHECK_CONTEXTJ
IDNA option to check for whether the input conforms to the CONTEXTJ rules.
Definition: uidna.h:84
UIDNA_CHECK_CONTEXTO
IDNA option to check for whether the input conforms to the CONTEXTO rules.
Definition: uidna.h:112
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:501
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:179
UIDNA_ERROR_EMPTY_LABEL
A non-final domain name label (or the whole domain name) is empty.
Definition: uidna.h:424
U_DEPRECATED
#define U_DEPRECATED
This is used to declare a function as a deprecated public ICU C API.
Definition: umachine.h:113
UIDNA_ERROR_DISALLOWED
A label or domain name contains disallowed characters.
Definition: uidna.h:463
UIDNA_ERROR_TRAILING_HYPHEN
A label ends with a hyphen-minus ('-').
Definition: uidna.h:448
UIDNAInfo::size
int16_t size
sizeof(UIDNAInfo)
Definition: uidna.h:181
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
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:535
UIDNA_NONTRANSITIONAL_TO_ASCII
IDNA option for nontransitional processing in ToASCII().
Definition: uidna.h:93
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:188
UIDNA_CHECK_BIDI
IDNA option to check for whether the input conforms to the BiDi rules.
Definition: uidna.h:76
UIDNAInfo::isTransitionalDifferent
UBool isTransitionalDifferent
Set to TRUE if transitional and nontransitional processing produce different results.
Definition: uidna.h:187
UIDNA_ALLOW_UNASSIGNED
Option to allow unassigned code points in domain names and labels.
Definition: uidna.h:59
UIDNA_ERROR_INVALID_ACE_LABEL
An ACE label does not contain a valid label string.
Definition: uidna.h:484
UIDNAInfo::reservedI3
int32_t reservedI3
Reserved field, do not use.
Definition: uidna.h:196
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:312
UIDNA
struct UIDNA UIDNA
C typedef for struct UIDNA.
Definition: uidna.h:120
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
parseerr.h
C API: Parse Error Information.
UIDNAInfo::errors
uint32_t errors
Bit set indicating IDNA processing errors.
Definition: uidna.h:194
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:507
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
UIDNA_ERROR_LABEL_TOO_LONG
A domain name label is longer than 63 bytes.
Definition: uidna.h:431
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:56
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:458
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:50
UIDNAInfo::reservedI2
int32_t reservedI2
Reserved field, do not use.
Definition: uidna.h:195
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:469
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:109
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234