ICU 52.1  52.1
uidna.h
Go to the documentation of this file.
1 /*
2  *******************************************************************************
3  *
4  * Copyright (C) 2003-2013, 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 
39 /*
40  * IDNA option bit set values.
41  */
42 enum {
109 };
110 
115 struct UIDNA;
116 typedef struct UIDNA UIDNA;
135 U_STABLE UIDNA * U_EXPORT2
136 uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode);
137 
143 U_STABLE void U_EXPORT2
144 uidna_close(UIDNA *idna);
145 
146 #if U_SHOW_CPLUSPLUS_API
147 
149 
160 
162 
163 #endif
164 
175 typedef struct UIDNAInfo {
177  int16_t size;
190  uint32_t errors;
191  int32_t reservedI2;
192  int32_t reservedI3;
193 } UIDNAInfo;
194 
199 #define UIDNA_INFO_INITIALIZER { \
200  (int16_t)sizeof(UIDNAInfo), \
201  FALSE, FALSE, \
202  0, 0, 0 }
203 
227 U_STABLE int32_t U_EXPORT2
228 uidna_labelToASCII(const UIDNA *idna,
229  const UChar *label, int32_t length,
230  UChar *dest, int32_t capacity,
231  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
232 
254 U_STABLE int32_t U_EXPORT2
255 uidna_labelToUnicode(const UIDNA *idna,
256  const UChar *label, int32_t length,
257  UChar *dest, int32_t capacity,
258  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
259 
283 U_STABLE int32_t U_EXPORT2
284 uidna_nameToASCII(const UIDNA *idna,
285  const UChar *name, int32_t length,
286  UChar *dest, int32_t capacity,
287  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
288 
310 U_STABLE int32_t U_EXPORT2
311 uidna_nameToUnicode(const UIDNA *idna,
312  const UChar *name, int32_t length,
313  UChar *dest, int32_t capacity,
314  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
315 
316 /* UTF-8 versions of the processing methods --------------------------------- */
317 
335 U_STABLE int32_t U_EXPORT2
336 uidna_labelToASCII_UTF8(const UIDNA *idna,
337  const char *label, int32_t length,
338  char *dest, int32_t capacity,
339  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
340 
358 U_STABLE int32_t U_EXPORT2
359 uidna_labelToUnicodeUTF8(const UIDNA *idna,
360  const char *label, int32_t length,
361  char *dest, int32_t capacity,
362  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
363 
381 U_STABLE int32_t U_EXPORT2
382 uidna_nameToASCII_UTF8(const UIDNA *idna,
383  const char *name, int32_t length,
384  char *dest, int32_t capacity,
385  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
386 
404 U_STABLE int32_t U_EXPORT2
405 uidna_nameToUnicodeUTF8(const UIDNA *idna,
406  const char *name, int32_t length,
407  char *dest, int32_t capacity,
408  UIDNAInfo *pInfo, UErrorCode *pErrorCode);
409 
410 /*
411  * IDNA error bit set values.
412  * When a domain name or label fails a processing step or does not meet the
413  * validity criteria, then one or more of these error bits are set.
414  */
415 enum {
504 };
505 
506 /* IDNA2003 API ------------------------------------------------------------- */
507 
567 U_STABLE int32_t U_EXPORT2
568 uidna_toASCII(const UChar* src, int32_t srcLength,
569  UChar* dest, int32_t destCapacity,
570  int32_t options,
571  UParseError* parseError,
572  UErrorCode* status);
573 
574 
615 U_STABLE int32_t U_EXPORT2
616 uidna_toUnicode(const UChar* src, int32_t srcLength,
617  UChar* dest, int32_t destCapacity,
618  int32_t options,
619  UParseError* parseError,
620  UErrorCode* status);
621 
622 
666 U_STABLE int32_t U_EXPORT2
667 uidna_IDNToASCII( const UChar* src, int32_t srcLength,
668  UChar* dest, int32_t destCapacity,
669  int32_t options,
670  UParseError* parseError,
671  UErrorCode* status);
672 
713 U_STABLE int32_t U_EXPORT2
714 uidna_IDNToUnicode( const UChar* src, int32_t srcLength,
715  UChar* dest, int32_t destCapacity,
716  int32_t options,
717  UParseError* parseError,
718  UErrorCode* status);
719 
754 U_STABLE int32_t U_EXPORT2
755 uidna_compare( const UChar *s1, int32_t length1,
756  const UChar *s2, int32_t length2,
757  int32_t options,
758  UErrorCode* status);
759 
760 #endif /* #if !UCONFIG_NO_IDNA */
761 
762 #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:64
A label contains hyphen-minus ('-') in the third and fourth positions.
Definition: uidna.h:449
A label does not meet the IDNA BiDi requirements (for right-to-left characters).
Definition: uidna.h:485
A label does not meet the IDNA CONTEXTJ requirements.
Definition: uidna.h:490
A label starts with a hyphen-minus ('-').
Definition: uidna.h:439
A label contains a dot=full stop.
Definition: uidna.h:471
A domain name is longer than 255 bytes in its storage form.
Definition: uidna.h:434
IDNA option for nontransitional processing in ToUnicode().
Definition: uidna.h:98
IDNA option to check for whether the input conforms to the CONTEXTJ rules.
Definition: uidna.h:80
IDNA option to check for whether the input conforms to the CONTEXTO rules.
Definition: uidna.h:108
struct UIDNAInfo UIDNAInfo
Output container for IDNA processing errors.
A label does not meet the IDNA CONTEXTO requirements for punctuation characters.
Definition: uidna.h:497
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:175
A non-final domain name label (or the whole domain name) is empty.
Definition: uidna.h:420
A label or domain name contains disallowed characters.
Definition: uidna.h:459
A label ends with a hyphen-minus ('-').
Definition: uidna.h:444
int16_t size
sizeof(UIDNAInfo)
Definition: uidna.h:177
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
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:290
IDNA option for nontransitional processing in ToASCII().
Definition: uidna.h:89
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
UBool reservedB3
Reserved field, do not use.
Definition: uidna.h:184
IDNA option to check for whether the input conforms to the BiDi rules.
Definition: uidna.h:72
UBool isTransitionalDifferent
Set to TRUE if transitional and nontransitional processing produce different results.
Definition: uidna.h:183
Option to allow unassigned code points in domain names and labels.
Definition: uidna.h:56
An ACE label does not contain a valid label string.
Definition: uidna.h:480
int32_t reservedI3
Reserved field, do not use.
Definition: uidna.h:192
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:278
struct UIDNA UIDNA
C typedef for struct UIDNA.
Definition: uidna.h:116
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
C API: Parse Error Information.
uint32_t errors
Bit set indicating IDNA processing errors.
Definition: uidna.h:190
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:503
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
A domain name label is longer than 63 bytes.
Definition: uidna.h:427
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:56
Basic definitions for ICU, for both C and C++ APIs.
A label starts with a combining mark.
Definition: uidna.h:454
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:48
int32_t reservedI2
Reserved field, do not use.
Definition: uidna.h:191
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:465
"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:109
int8_t UBool
The ICU boolean type.
Definition: umachine.h:200