Loading...
Searching...
No Matches
uidna.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
* Copyright (C) 2003-2014, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: uidna.h
* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
* created on: 2003feb1
* created by: Ram Viswanadha
*/
#ifndef __UIDNA_H__
#define __UIDNA_H__
#include "unicode/utypes.h"
#if !UCONFIG_NO_IDNA
#include <stdbool.h>
#include "unicode/parseerr.h"
#if U_SHOW_CPLUSPLUS_API
#include "unicode/localpointer.h"
#endif // U_SHOW_CPLUSPLUS_API
/*
* IDNA option bit set values.
*/
enum {
UIDNA_DEFAULT=0x30,
#ifndef U_HIDE_DEPRECATED_API
UIDNA_ALLOW_UNASSIGNED=1,
#endif /* U_HIDE_DEPRECATED_API */
UIDNA_USE_STD3_RULES=2,
UIDNA_CHECK_BIDI=4,
UIDNA_CHECK_CONTEXTJ=8,
UIDNA_NONTRANSITIONAL_TO_ASCII=0x10,
UIDNA_NONTRANSITIONAL_TO_UNICODE=0x20,
UIDNA_CHECK_CONTEXTO=0x40
};
struct UIDNA;
typedef struct UIDNA UIDNA;
U_CAPI UIDNA * U_EXPORT2
uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode);
U_CAPI void U_EXPORT2
uidna_close(UIDNA *idna);
#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
U_DEFINE_LOCAL_OPEN_POINTER(LocalUIDNAPointer, UIDNA, uidna_close);
U_NAMESPACE_END
#endif
typedef struct UIDNAInfo {
int16_t size;
UBool isTransitionalDifferent;
UBool reservedB3;
uint32_t errors;
int32_t reservedI2;
int32_t reservedI3;
} UIDNAInfo;
#define UIDNA_INFO_INITIALIZER { \
(int16_t)sizeof(UIDNAInfo), \
false, false, \
0, 0, 0 }
U_CAPI int32_t U_EXPORT2
uidna_labelToASCII(const UIDNA *idna,
const UChar *label, int32_t length,
UChar *dest, int32_t capacity,
UIDNAInfo *pInfo, UErrorCode *pErrorCode);
U_CAPI int32_t U_EXPORT2
uidna_labelToUnicode(const UIDNA *idna,
const UChar *label, int32_t length,
UChar *dest, int32_t capacity,
UIDNAInfo *pInfo, UErrorCode *pErrorCode);
U_CAPI int32_t U_EXPORT2
uidna_nameToASCII(const UIDNA *idna,
const UChar *name, int32_t length,
UChar *dest, int32_t capacity,
UIDNAInfo *pInfo, UErrorCode *pErrorCode);
U_CAPI int32_t U_EXPORT2
uidna_nameToUnicode(const UIDNA *idna,
const UChar *name, int32_t length,
UChar *dest, int32_t capacity,
UIDNAInfo *pInfo, UErrorCode *pErrorCode);
/* UTF-8 versions of the processing methods --------------------------------- */
U_CAPI int32_t U_EXPORT2
uidna_labelToASCII_UTF8(const UIDNA *idna,
const char *label, int32_t length,
char *dest, int32_t capacity,
UIDNAInfo *pInfo, UErrorCode *pErrorCode);
U_CAPI int32_t U_EXPORT2
uidna_labelToUnicodeUTF8(const UIDNA *idna,
const char *label, int32_t length,
char *dest, int32_t capacity,
UIDNAInfo *pInfo, UErrorCode *pErrorCode);
U_CAPI int32_t U_EXPORT2
uidna_nameToASCII_UTF8(const UIDNA *idna,
const char *name, int32_t length,
char *dest, int32_t capacity,
UIDNAInfo *pInfo, UErrorCode *pErrorCode);
U_CAPI int32_t U_EXPORT2
uidna_nameToUnicodeUTF8(const UIDNA *idna,
const char *name, int32_t length,
char *dest, int32_t capacity,
UIDNAInfo *pInfo, UErrorCode *pErrorCode);
/*
* IDNA error bit set values.
* When a domain name or label fails a processing step or does not meet the
* validity criteria, then one or more of these error bits are set.
*/
enum {
UIDNA_ERROR_EMPTY_LABEL=1,
UIDNA_ERROR_LABEL_TOO_LONG=2,
UIDNA_ERROR_DOMAIN_NAME_TOO_LONG=4,
UIDNA_ERROR_LEADING_HYPHEN=8,
UIDNA_ERROR_TRAILING_HYPHEN=0x10,
UIDNA_ERROR_HYPHEN_3_4=0x20,
UIDNA_ERROR_LEADING_COMBINING_MARK=0x40,
UIDNA_ERROR_DISALLOWED=0x80,
UIDNA_ERROR_PUNYCODE=0x100,
UIDNA_ERROR_LABEL_HAS_DOT=0x200,
UIDNA_ERROR_INVALID_ACE_LABEL=0x400,
UIDNA_ERROR_BIDI=0x800,
UIDNA_ERROR_CONTEXTJ=0x1000,
UIDNA_ERROR_CONTEXTO_PUNCTUATION=0x2000,
UIDNA_ERROR_CONTEXTO_DIGITS=0x4000
};
#ifndef U_HIDE_DEPRECATED_API
/* IDNA2003 API ------------------------------------------------------------- */
U_DEPRECATED int32_t U_EXPORT2
uidna_toASCII(const UChar* src, int32_t srcLength,
UChar* dest, int32_t destCapacity,
int32_t options,
UParseError* parseError,
UErrorCode* status);
U_DEPRECATED int32_t U_EXPORT2
uidna_toUnicode(const UChar* src, int32_t srcLength,
UChar* dest, int32_t destCapacity,
int32_t options,
UParseError* parseError,
UErrorCode* status);
U_DEPRECATED int32_t U_EXPORT2
uidna_IDNToASCII( const UChar* src, int32_t srcLength,
UChar* dest, int32_t destCapacity,
int32_t options,
UParseError* parseError,
UErrorCode* status);
U_DEPRECATED int32_t U_EXPORT2
uidna_IDNToUnicode( const UChar* src, int32_t srcLength,
UChar* dest, int32_t destCapacity,
int32_t options,
UParseError* parseError,
UErrorCode* status);
U_DEPRECATED int32_t U_EXPORT2
uidna_compare( const UChar *s1, int32_t length1,
const UChar *s2, int32_t length2,
int32_t options,
UErrorCode* status);
#endif /* U_HIDE_DEPRECATED_API */
#endif /* #if !UCONFIG_NO_IDNA */
#endif
LocalUIDNAPointer
"Smart pointer" class, closes a UIDNA via uidna_close().
localpointer.h
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
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:548
parseerr.h
C API: Parse Error Information.
UIDNAInfo
Output container for IDNA processing errors.
Definition uidna.h:203
UIDNAInfo::size
int16_t size
sizeof(UIDNAInfo)
Definition uidna.h:205
UIDNAInfo::reservedI3
int32_t reservedI3
Reserved field, do not use.
Definition uidna.h:220
UIDNAInfo::errors
uint32_t errors
Bit set indicating IDNA processing errors.
Definition uidna.h:218
UIDNAInfo::isTransitionalDifferent
UBool isTransitionalDifferent
Set to true if transitional and nontransitional processing produce different results.
Definition uidna.h:211
UIDNAInfo::reservedB3
UBool reservedB3
Reserved field, do not use.
Definition uidna.h:212
UIDNAInfo::reservedI2
int32_t reservedI2
Reserved field, do not use.
Definition uidna.h:219
UParseError
A UParseError struct is used to returned detailed information about parsing errors.
Definition parseerr.h:58
UIDNA
struct UIDNA UIDNA
C typedef for struct UIDNA.
Definition uidna.h:142
UIDNA_ERROR_CONTEXTO_DIGITS
@ UIDNA_ERROR_CONTEXTO_DIGITS
A label does not meet the IDNA CONTEXTO requirements for digits.
Definition uidna.h:531
UIDNA_ERROR_TRAILING_HYPHEN
@ UIDNA_ERROR_TRAILING_HYPHEN
A label ends with a hyphen-minus ('-').
Definition uidna.h:472
UIDNA_ERROR_LEADING_COMBINING_MARK
@ UIDNA_ERROR_LEADING_COMBINING_MARK
A label starts with a combining mark.
Definition uidna.h:482
UIDNA_ERROR_LABEL_TOO_LONG
@ UIDNA_ERROR_LABEL_TOO_LONG
A domain name label is longer than 63 bytes.
Definition uidna.h:455
UIDNA_ERROR_CONTEXTJ
@ UIDNA_ERROR_CONTEXTJ
A label does not meet the IDNA CONTEXTJ requirements.
Definition uidna.h:518
UIDNA_ERROR_DISALLOWED
@ UIDNA_ERROR_DISALLOWED
A label or domain name contains disallowed characters.
Definition uidna.h:487
UIDNA_ERROR_LABEL_HAS_DOT
@ UIDNA_ERROR_LABEL_HAS_DOT
A label contains a dot=full stop.
Definition uidna.h:499
UIDNA_ERROR_BIDI
@ UIDNA_ERROR_BIDI
A label does not meet the IDNA BiDi requirements (for right-to-left characters).
Definition uidna.h:513
UIDNA_ERROR_HYPHEN_3_4
@ UIDNA_ERROR_HYPHEN_3_4
A label contains hyphen-minus ('-') in the third and fourth positions.
Definition uidna.h:477
UIDNA_ERROR_PUNYCODE
@ UIDNA_ERROR_PUNYCODE
A label starts with "xn--" but does not contain valid Punycode.
Definition uidna.h:493
UIDNA_ERROR_DOMAIN_NAME_TOO_LONG
@ UIDNA_ERROR_DOMAIN_NAME_TOO_LONG
A domain name is longer than 255 bytes in its storage form.
Definition uidna.h:462
UIDNA_ERROR_LEADING_HYPHEN
@ UIDNA_ERROR_LEADING_HYPHEN
A label starts with a hyphen-minus ('-').
Definition uidna.h:467
UIDNA_ERROR_CONTEXTO_PUNCTUATION
@ UIDNA_ERROR_CONTEXTO_PUNCTUATION
A label does not meet the IDNA CONTEXTO requirements for punctuation characters.
Definition uidna.h:525
UIDNA_ERROR_EMPTY_LABEL
@ UIDNA_ERROR_EMPTY_LABEL
A non-final domain name label (or the whole domain name) is empty.
Definition uidna.h:448
UIDNA_ERROR_INVALID_ACE_LABEL
@ UIDNA_ERROR_INVALID_ACE_LABEL
An ACE label does not contain a valid label string.
Definition uidna.h:508
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_close
U_CAPI void uidna_close(UIDNA *idna)
Closes a UIDNA instance.
uidna_nameToUnicode
U_CAPI 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_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_CHECK_CONTEXTJ
@ UIDNA_CHECK_CONTEXTJ
IDNA option to check for whether the input conforms to the CONTEXTJ rules.
Definition uidna.h:98
UIDNA_NONTRANSITIONAL_TO_ASCII
@ UIDNA_NONTRANSITIONAL_TO_ASCII
IDNA option for nontransitional processing in ToASCII().
Definition uidna.h:111
UIDNA_ALLOW_UNASSIGNED
@ UIDNA_ALLOW_UNASSIGNED
Option to allow unassigned code points in domain names and labels.
Definition uidna.h:73
UIDNA_CHECK_CONTEXTO
@ UIDNA_CHECK_CONTEXTO
IDNA option to check for whether the input conforms to the CONTEXTO rules.
Definition uidna.h:134
UIDNA_CHECK_BIDI
@ UIDNA_CHECK_BIDI
IDNA option to check for whether the input conforms to the BiDi rules.
Definition uidna.h:90
UIDNA_USE_STD3_RULES
@ 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:82
UIDNA_DEFAULT
@ UIDNA_DEFAULT
Default options value: UTS #46 nontransitional processing.
Definition uidna.h:64
UIDNA_NONTRANSITIONAL_TO_UNICODE
@ UIDNA_NONTRANSITIONAL_TO_UNICODE
IDNA option for nontransitional processing in ToUnicode().
Definition uidna.h:124
uidna_labelToASCII
U_CAPI 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_nameToASCII_UTF8
U_CAPI 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_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_nameToASCII
U_CAPI 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_labelToUnicodeUTF8
U_CAPI 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_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_labelToASCII_UTF8
U_CAPI 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_labelToUnicode
U_CAPI 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.
uidna_openUTS46
U_CAPI UIDNA * uidna_openUTS46(uint32_t options, UErrorCode *pErrorCode)
Returns a UIDNA instance which implements UTS #46.
uidna_nameToUnicodeUTF8
U_CAPI 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_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.
UChar
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition umachine.h:400
U_DEPRECATED
#define U_DEPRECATED
This is used to declare a function as a deprecated public ICU C API.
Definition umachine.h:116
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
U_CAPI
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition umachine.h:110
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509