ICU 62.1 62.1
idna.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* Copyright (C) 2010-2012, International Business Machines
6* Corporation and others. All Rights Reserved.
7*******************************************************************************
8* file name: idna.h
9* encoding: UTF-8
10* tab size: 8 (not used)
11* indentation:4
12*
13* created on: 2010mar05
14* created by: Markus W. Scherer
15*/
16
17#ifndef __IDNA_H__
18#define __IDNA_H__
19
25#include "unicode/utypes.h"
26
27#if !UCONFIG_NO_IDNA
28
29#include "unicode/bytestream.h"
30#include "unicode/stringpiece.h"
31#include "unicode/uidna.h"
32#include "unicode/unistr.h"
33
35
36class IDNAInfo;
37
50class U_COMMON_API IDNA : public UObject {
51public:
57
91 static IDNA *
92 createUTS46Instance(uint32_t options, UErrorCode &errorCode);
93
114 virtual UnicodeString &
116 IDNAInfo &info, UErrorCode &errorCode) const = 0;
117
136 virtual UnicodeString &
138 IDNAInfo &info, UErrorCode &errorCode) const = 0;
139
160 virtual UnicodeString &
162 IDNAInfo &info, UErrorCode &errorCode) const = 0;
163
182 virtual UnicodeString &
184 IDNAInfo &info, UErrorCode &errorCode) const = 0;
185
186 // UTF-8 versions of the processing methods ---------------------------- ***
187
202 virtual void
204 IDNAInfo &info, UErrorCode &errorCode) const;
205
220 virtual void
222 IDNAInfo &info, UErrorCode &errorCode) const;
223
238 virtual void
240 IDNAInfo &info, UErrorCode &errorCode) const;
241
256 virtual void
258 IDNAInfo &info, UErrorCode &errorCode) const;
259};
260
261class UTS46;
262
269public:
274 IDNAInfo() : errors(0), labelErrors(0), isTransDiff(FALSE), isBiDi(FALSE), isOkBiDi(TRUE) {}
280 UBool hasErrors() const { return errors!=0; }
287 uint32_t getErrors() const { return errors; }
301 UBool isTransitionalDifferent() const { return isTransDiff; }
302
303private:
304 friend class UTS46;
305
306 IDNAInfo(const IDNAInfo &other); // no copying
307 IDNAInfo &operator=(const IDNAInfo &other); // no copying
308
309 void reset() {
310 errors=labelErrors=0;
311 isTransDiff=FALSE;
312 isBiDi=FALSE;
313 isOkBiDi=TRUE;
314 }
315
316 uint32_t errors, labelErrors;
317 UBool isTransDiff;
318 UBool isBiDi;
319 UBool isOkBiDi;
320};
321
323
324#endif // UCONFIG_NO_IDNA
325#endif // __IDNA_H__
C++ API: Interface for writing bytes, and implementation classes.
A ByteSink can be filled with bytes.
Definition bytestream.h:50
Output container for IDNA processing errors.
Definition idna.h:268
uint32_t getErrors() const
Returns a bit set indicating IDNA processing errors.
Definition idna.h:287
UBool hasErrors() const
Were there IDNA processing errors?
Definition idna.h:280
UBool isTransitionalDifferent() const
Returns TRUE if transitional and nontransitional processing produce different results.
Definition idna.h:301
IDNAInfo()
Constructor for stack allocation.
Definition idna.h:274
Abstract base class for IDNA processing.
Definition idna.h:50
virtual void labelToASCII_UTF8(StringPiece label, ByteSink &dest, IDNAInfo &info, UErrorCode &errorCode) const
Converts a single domain name label into its ASCII form for DNS lookup.
virtual void nameToASCII_UTF8(StringPiece name, ByteSink &dest, IDNAInfo &info, UErrorCode &errorCode) const
Converts a whole domain name into its ASCII form for DNS lookup.
static IDNA * createUTS46Instance(uint32_t options, UErrorCode &errorCode)
Returns an IDNA instance which implements UTS #46.
virtual void nameToUnicodeUTF8(StringPiece name, ByteSink &dest, IDNAInfo &info, UErrorCode &errorCode) const
Converts a whole domain name into its Unicode form for human-readable display.
virtual UnicodeString & labelToASCII(const UnicodeString &label, UnicodeString &dest, IDNAInfo &info, UErrorCode &errorCode) const =0
Converts a single domain name label into its ASCII form for DNS lookup.
virtual void labelToUnicodeUTF8(StringPiece label, ByteSink &dest, IDNAInfo &info, UErrorCode &errorCode) const
Converts a single domain name label into its Unicode form for human-readable display.
~IDNA()
Destructor.
virtual UnicodeString & nameToUnicode(const UnicodeString &name, UnicodeString &dest, IDNAInfo &info, UErrorCode &errorCode) const =0
Converts a whole domain name into its Unicode form for human-readable display.
virtual UnicodeString & nameToASCII(const UnicodeString &name, UnicodeString &dest, IDNAInfo &info, UErrorCode &errorCode) const =0
Converts a whole domain name into its ASCII form for DNS lookup.
virtual UnicodeString & labelToUnicode(const UnicodeString &label, UnicodeString &dest, IDNAInfo &info, UErrorCode &errorCode) const =0
Converts a single domain name label into its Unicode form for human-readable display.
A string-like object that points to a sized piece of memory.
Definition stringpiece.h:54
UMemory is the common ICU base class.
Definition uobject.h:112
UObject is the common ICU "boilerplate" class.
Definition uobject.h:223
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:287
C++ API: StringPiece: Read-only byte string wrapper class.
C API: Internationalizing Domain Names in Applications (IDNA)
int8_t UBool
The ICU boolean type.
Definition umachine.h:236
#define TRUE
The TRUE value of a UBool.
Definition umachine.h:240
#define FALSE
The FALSE value of a UBool.
Definition umachine.h:244
C++ API: Unicode String.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition utypes.h:396
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition utypes.h:359
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:138
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:137