ICU 66.1 66.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
27#include "unicode/parseerr.h"
28
43/*
44 * IDNA option bit set values.
45 */
46enum {
53#ifndef U_HIDE_DEPRECATED_API
62#endif /* U_HIDE_DEPRECATED_API */
116
121struct UIDNA;
122typedef struct UIDNA UIDNA;
141U_STABLE UIDNA * U_EXPORT2
142uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode);
143
149U_STABLE void U_EXPORT2
151
152#if U_SHOW_CPLUSPLUS_API
153
154U_NAMESPACE_BEGIN
155
166
167U_NAMESPACE_END
168
169#endif
170
181typedef struct UIDNAInfo {
183 int16_t size;
196 uint32_t errors;
197 int32_t reservedI2;
198 int32_t reservedI3;
200
205#define UIDNA_INFO_INITIALIZER { \
206 (int16_t)sizeof(UIDNAInfo), \
207 FALSE, FALSE, \
208 0, 0, 0 }
209
233U_STABLE int32_t U_EXPORT2
235 const UChar *label, int32_t length,
236 UChar *dest, int32_t capacity,
237 UIDNAInfo *pInfo, UErrorCode *pErrorCode);
238
260U_STABLE int32_t U_EXPORT2
262 const UChar *label, int32_t length,
263 UChar *dest, int32_t capacity,
264 UIDNAInfo *pInfo, UErrorCode *pErrorCode);
265
289U_STABLE int32_t U_EXPORT2
291 const UChar *name, int32_t length,
292 UChar *dest, int32_t capacity,
293 UIDNAInfo *pInfo, UErrorCode *pErrorCode);
294
316U_STABLE int32_t U_EXPORT2
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
341U_STABLE int32_t U_EXPORT2
343 const char *label, int32_t length,
344 char *dest, int32_t capacity,
345 UIDNAInfo *pInfo, UErrorCode *pErrorCode);
346
364U_STABLE int32_t U_EXPORT2
366 const char *label, int32_t length,
367 char *dest, int32_t capacity,
368 UIDNAInfo *pInfo, UErrorCode *pErrorCode);
369
387U_STABLE int32_t U_EXPORT2
389 const char *name, int32_t length,
390 char *dest, int32_t capacity,
391 UIDNAInfo *pInfo, UErrorCode *pErrorCode);
392
410U_STABLE int32_t U_EXPORT2
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 */
421enum {
511
512#ifndef U_HIDE_DEPRECATED_API
513
514/* IDNA2003 API ------------------------------------------------------------- */
515
575U_DEPRECATED int32_t U_EXPORT2
576uidna_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
623U_DEPRECATED int32_t U_EXPORT2
624uidna_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
674U_DEPRECATED int32_t U_EXPORT2
675uidna_IDNToASCII( const UChar* src, int32_t srcLength,
676 UChar* dest, int32_t destCapacity,
677 int32_t options,
678 UParseError* parseError,
679 UErrorCode* status);
680
721U_DEPRECATED int32_t U_EXPORT2
722uidna_IDNToUnicode( const UChar* src, int32_t srcLength,
723 UChar* dest, int32_t destCapacity,
724 int32_t options,
725 UParseError* parseError,
726 UErrorCode* status);
727
762U_DEPRECATED int32_t U_EXPORT2
763uidna_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
"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:562
C API: Parse Error Information.
Output container for IDNA processing errors.
Definition: uidna.h:181
int16_t size
sizeof(UIDNAInfo)
Definition: uidna.h:183
int32_t reservedI3
Reserved field, do not use.
Definition: uidna.h:198
uint32_t errors
Bit set indicating IDNA processing errors.
Definition: uidna.h:196
UBool isTransitionalDifferent
Set to TRUE if transitional and nontransitional processing produce different results.
Definition: uidna.h:189
UBool reservedB3
Reserved field, do not use.
Definition: uidna.h:190
int32_t reservedI2
Reserved field, do not use.
Definition: uidna.h:197
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:509
@ UIDNA_ERROR_TRAILING_HYPHEN
A label ends with a hyphen-minus ('-').
Definition: uidna.h:450
@ UIDNA_ERROR_LEADING_COMBINING_MARK
A label starts with a combining mark.
Definition: uidna.h:460
@ UIDNA_ERROR_LABEL_TOO_LONG
A domain name label is longer than 63 bytes.
Definition: uidna.h:433
@ UIDNA_ERROR_CONTEXTJ
A label does not meet the IDNA CONTEXTJ requirements.
Definition: uidna.h:496
@ UIDNA_ERROR_DISALLOWED
A label or domain name contains disallowed characters.
Definition: uidna.h:465
@ UIDNA_ERROR_LABEL_HAS_DOT
A label contains a dot=full stop.
Definition: uidna.h:477
@ UIDNA_ERROR_BIDI
A label does not meet the IDNA BiDi requirements (for right-to-left characters).
Definition: uidna.h:491
@ UIDNA_ERROR_HYPHEN_3_4
A label contains hyphen-minus ('-') in the third and fourth positions.
Definition: uidna.h:455
@ UIDNA_ERROR_PUNYCODE
A label starts with "xn--" but does not contain valid Punycode.
Definition: uidna.h:471
@ UIDNA_ERROR_DOMAIN_NAME_TOO_LONG
A domain name is longer than 255 bytes in its storage form.
Definition: uidna.h:440
@ UIDNA_ERROR_LEADING_HYPHEN
A label starts with a hyphen-minus ('-').
Definition: uidna.h:445
@ UIDNA_ERROR_CONTEXTO_PUNCTUATION
A label does not meet the IDNA CONTEXTO requirements for punctuation characters.
Definition: uidna.h:503
@ UIDNA_ERROR_EMPTY_LABEL
A non-final domain name label (or the whole domain name) is empty.
Definition: uidna.h:426
@ UIDNA_ERROR_INVALID_ACE_LABEL
An ACE label does not contain a valid label string.
Definition: uidna.h:486
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.
UIDNA * uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode)
Returns a UIDNA instance which implements UTS #46.
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.
struct UIDNA UIDNA
C typedef for struct UIDNA.
Definition: uidna.h:122
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.
void uidna_close(UIDNA *idna)
Closes a UIDNA instance.
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:86
@ UIDNA_NONTRANSITIONAL_TO_ASCII
IDNA option for nontransitional processing in ToASCII().
Definition: uidna.h:95
@ UIDNA_ALLOW_UNASSIGNED
Option to allow unassigned code points in domain names and labels.
Definition: uidna.h:61
@ UIDNA_CHECK_CONTEXTO
IDNA option to check for whether the input conforms to the CONTEXTO rules.
Definition: uidna.h:114
@ UIDNA_CHECK_BIDI
IDNA option to check for whether the input conforms to the BiDi rules.
Definition: uidna.h:78
@ 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_DEFAULT
Default options value: None of the other options are set.
Definition: uidna.h:52
@ UIDNA_NONTRANSITIONAL_TO_UNICODE
IDNA option for nontransitional processing in ToUnicode().
Definition: uidna.h:104
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_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.
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.
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.
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.
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_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.
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_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:115
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261
uint16_t UChar
The base type for UTF-16 code units and pointers.
Definition: umachine.h:378
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:111
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415