ICU 57.1 57.1
idna.h
Go to the documentation of this file.
1/*
2*******************************************************************************
3* Copyright (C) 2010-2012, International Business Machines
4* Corporation and others. All Rights Reserved.
5*******************************************************************************
6* file name: idna.h
7* encoding: US-ASCII
8* tab size: 8 (not used)
9* indentation:4
10*
11* created on: 2010mar05
12* created by: Markus W. Scherer
13*/
14
15#ifndef __IDNA_H__
16#define __IDNA_H__
17
23#include "unicode/utypes.h"
24
25#if !UCONFIG_NO_IDNA
26
27#include "unicode/bytestream.h"
28#include "unicode/stringpiece.h"
29#include "unicode/uidna.h"
30#include "unicode/unistr.h"
31
33
34class IDNAInfo;
35
48class U_COMMON_API IDNA : public UObject {
49public:
55
89 static IDNA *
90 createUTS46Instance(uint32_t options, UErrorCode &errorCode);
91
112 virtual UnicodeString &
114 IDNAInfo &info, UErrorCode &errorCode) const = 0;
115
134 virtual UnicodeString &
136 IDNAInfo &info, UErrorCode &errorCode) const = 0;
137
158 virtual UnicodeString &
160 IDNAInfo &info, UErrorCode &errorCode) const = 0;
161
180 virtual UnicodeString &
182 IDNAInfo &info, UErrorCode &errorCode) const = 0;
183
184 // UTF-8 versions of the processing methods ---------------------------- ***
185
200 virtual void
202 IDNAInfo &info, UErrorCode &errorCode) const;
203
218 virtual void
220 IDNAInfo &info, UErrorCode &errorCode) const;
221
236 virtual void
238 IDNAInfo &info, UErrorCode &errorCode) const;
239
254 virtual void
256 IDNAInfo &info, UErrorCode &errorCode) const;
257};
258
259class UTS46;
260
267public:
272 IDNAInfo() : errors(0), labelErrors(0), isTransDiff(FALSE), isBiDi(FALSE), isOkBiDi(TRUE) {}
278 UBool hasErrors() const { return errors!=0; }
285 uint32_t getErrors() const { return errors; }
299 UBool isTransitionalDifferent() const { return isTransDiff; }
300
301private:
302 friend class UTS46;
303
304 IDNAInfo(const IDNAInfo &other); // no copying
305 IDNAInfo &operator=(const IDNAInfo &other); // no copying
306
307 void reset() {
308 errors=labelErrors=0;
309 isTransDiff=FALSE;
310 isBiDi=FALSE;
311 isOkBiDi=TRUE;
312 }
313
314 uint32_t errors, labelErrors;
315 UBool isTransDiff;
316 UBool isBiDi;
317 UBool isOkBiDi;
318};
319
321
322#endif // UCONFIG_NO_IDNA
323#endif // __IDNA_H__
C++ API: Interface for writing bytes, and implementation classes.
A ByteSink can be filled with bytes.
Definition bytestream.h:48
Output container for IDNA processing errors.
Definition idna.h:266
uint32_t getErrors() const
Returns a bit set indicating IDNA processing errors.
Definition idna.h:285
UBool isTransitionalDifferent() const
Returns TRUE if transitional and nontransitional processing produce different results.
Definition idna.h:299
UBool hasErrors() const
Were there IDNA processing errors?
Definition idna.h:278
IDNAInfo()
Constructor for stack allocation.
Definition idna.h:272
Abstract base class for IDNA processing.
Definition idna.h:48
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.
virtual void nameToUnicodeUTF8(const StringPiece &name, ByteSink &dest, IDNAInfo &info, UErrorCode &errorCode) const
Converts a whole domain name into its Unicode form for human-readable display.
virtual void labelToUnicodeUTF8(const StringPiece &label, ByteSink &dest, IDNAInfo &info, UErrorCode &errorCode) const
Converts a single domain name label into its Unicode form for human-readable display.
virtual void nameToASCII_UTF8(const StringPiece &name, ByteSink &dest, IDNAInfo &info, UErrorCode &errorCode) const
Converts a whole domain name into its ASCII form for DNS lookup.
virtual void labelToASCII_UTF8(const StringPiece &label, ByteSink &dest, IDNAInfo &info, UErrorCode &errorCode) const
Converts a single domain name label into its ASCII form for DNS lookup.
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.
~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 & 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.
static IDNA * createUTS46Instance(uint32_t options, UErrorCode &errorCode)
Returns an IDNA instance which implements UTS #46.
A string-like object that points to a sized piece of memory.
Definition stringpiece.h:52
UMemory is the common ICU base class.
Definition uobject.h:110
UObject is the common ICU "boilerplate" class.
Definition uobject.h:221
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:294
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:234
#define TRUE
The TRUE value of a UBool.
Definition umachine.h:238
#define FALSE
The FALSE value of a UBool.
Definition umachine.h:242
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:476
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition utypes.h:357
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:129