ICU 65.1 65.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 U_SHOW_CPLUSPLUS_API
28
29 #if !UCONFIG_NO_IDNA
30
31 #include "unicode/bytestream.h"
32 #include "unicode/stringpiece.h"
33 #include "unicode/uidna.h"
34 #include "unicode/unistr.h"
35
36 U_NAMESPACE_BEGIN
37
38 class IDNAInfo;
39
52 class U_COMMON_API IDNA : public UObject {
53 public:
58 ~IDNA();
59
93 static IDNA *
94 createUTS46Instance(uint32_t options, UErrorCode &errorCode);
95
116 virtual UnicodeString &
117 labelToASCII(const UnicodeString &label, UnicodeString &dest,
118 IDNAInfo &info, UErrorCode &errorCode) const = 0;
119
138 virtual UnicodeString &
139 labelToUnicode(const UnicodeString &label, UnicodeString &dest,
140 IDNAInfo &info, UErrorCode &errorCode) const = 0;
141
162 virtual UnicodeString &
163 nameToASCII(const UnicodeString &name, UnicodeString &dest,
164 IDNAInfo &info, UErrorCode &errorCode) const = 0;
165
184 virtual UnicodeString &
185 nameToUnicode(const UnicodeString &name, UnicodeString &dest,
186 IDNAInfo &info, UErrorCode &errorCode) const = 0;
187
188 // UTF-8 versions of the processing methods ---------------------------- ***
189
204 virtual void
205 labelToASCII_UTF8(StringPiece label, ByteSink &dest,
206 IDNAInfo &info, UErrorCode &errorCode) const;
207
222 virtual void
223 labelToUnicodeUTF8(StringPiece label, ByteSink &dest,
224 IDNAInfo &info, UErrorCode &errorCode) const;
225
240 virtual void
241 nameToASCII_UTF8(StringPiece name, ByteSink &dest,
242 IDNAInfo &info, UErrorCode &errorCode) const;
243
258 virtual void
259 nameToUnicodeUTF8(StringPiece name, ByteSink &dest,
260 IDNAInfo &info, UErrorCode &errorCode) const;
261 };
262
263 class UTS46;
264
270 class U_COMMON_API IDNAInfo : public UMemory {
271 public:
276 IDNAInfo() : errors(0), labelErrors(0), isTransDiff(FALSE), isBiDi(FALSE), isOkBiDi(TRUE) {}
282 UBool hasErrors() const { return errors!=0; }
289 uint32_t getErrors() const { return errors; }
303 UBool isTransitionalDifferent() const { return isTransDiff; }
304
305 private:
306 friend class UTS46;
307
308 IDNAInfo(const IDNAInfo &other); // no copying
309 IDNAInfo &operator=(const IDNAInfo &other); // no copying
310
311 void reset() {
312 errors=labelErrors=0;
313 isTransDiff=FALSE;
314 isBiDi=FALSE;
315 isOkBiDi=TRUE;
316 }
317
318 uint32_t errors, labelErrors;
319 UBool isTransDiff;
320 UBool isBiDi;
321 UBool isOkBiDi;
322 };
323
324 U_NAMESPACE_END
325
326 #endif // UCONFIG_NO_IDNA
327
328 #endif /* U_SHOW_CPLUSPLUS_API */
329
330 #endif // __IDNA_H__
icu::IDNAInfo
Output container for IDNA processing errors.
Definition: idna.h:270
icu::IDNAInfo::getErrors
uint32_t getErrors() const
Returns a bit set indicating IDNA processing errors.
Definition: idna.h:289
icu::IDNAInfo::isTransitionalDifferent
UBool isTransitionalDifferent() const
Returns TRUE if transitional and nontransitional processing produce different results.
Definition: idna.h:303
icu::IDNAInfo::IDNAInfo
IDNAInfo()
Constructor for stack allocation.
Definition: idna.h:276
unistr.h
C++ API: Unicode String.
icu::ByteSink
A ByteSink can be filled with bytes.
Definition: bytestream.h:53
stringpiece.h
C++ API: StringPiece: Read-only byte string wrapper class.
bytestream.h
C++ API: Interface for writing bytes, and implementation classes.
TRUE
#define TRUE
The TRUE value of a UBool.
Definition: umachine.h:265
uidna.h
C API: Internationalizing Domain Names in Applications (IDNA)
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
FALSE
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:269
U_COMMON_API
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
Definition: utypes.h:300
icu::IDNAInfo::hasErrors
UBool hasErrors() const
Were there IDNA processing errors?
Definition: idna.h:282
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:294
icu::IDNA
Abstract base class for IDNA processing.
Definition: idna.h:52
icu::StringPiece
A string-like object that points to a sized piece of memory.
Definition: stringpiece.h:60
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::UMemory
UMemory is the common ICU base class.
Definition: uobject.h:115
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261