ICU4C 79
Loading...
Searching...
No Matches
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
24
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
36U_NAMESPACE_BEGIN
37
38class IDNAInfo;
39
52class U_COMMON_API IDNA : public UObject {
53public:
59
96 static IDNA *
97 createUTS46Instance(uint32_t options, UErrorCode &errorCode);
98
119 virtual UnicodeString&
121 UnicodeString& dest U_LIFETIME_BOUND,
122 IDNAInfo& info,
123 UErrorCode& errorCode) const = 0;
124
143 virtual UnicodeString&
145 UnicodeString& dest U_LIFETIME_BOUND,
146 IDNAInfo& info,
147 UErrorCode& errorCode) const = 0;
148
169 virtual UnicodeString&
171 UnicodeString& dest U_LIFETIME_BOUND,
172 IDNAInfo& info,
173 UErrorCode& errorCode) const = 0;
174
193 virtual UnicodeString&
195 UnicodeString& dest U_LIFETIME_BOUND,
196 IDNAInfo& info,
197 UErrorCode& errorCode) const = 0;
198
199 // UTF-8 versions of the processing methods ---------------------------- ***
200
214 virtual void
216 IDNAInfo &info, UErrorCode &errorCode) const;
217
231 virtual void
233 IDNAInfo &info, UErrorCode &errorCode) const;
234
248 virtual void
250 IDNAInfo &info, UErrorCode &errorCode) const;
251
265 virtual void
267 IDNAInfo &info, UErrorCode &errorCode) const;
268};
269
270class UTS46;
271
278public:
283 IDNAInfo() : errors(0), labelErrors(0), isTransDiff(false), isBiDi(false), isOkBiDi(true) {}
289 UBool hasErrors() const { return errors!=0; }
296 uint32_t getErrors() const { return errors; }
310 UBool isTransitionalDifferent() const { return isTransDiff; }
311
312private:
313 friend class UTS46;
314
315 IDNAInfo(const IDNAInfo &other) = delete; // no copying
316 IDNAInfo &operator=(const IDNAInfo &other) = delete; // no copying
317
318 void reset() {
319 errors=labelErrors=0;
320 isTransDiff=false;
321 isBiDi=false;
322 isOkBiDi=true;
323 }
324
325 uint32_t errors, labelErrors;
326 UBool isTransDiff;
327 UBool isBiDi;
328 UBool isOkBiDi;
329};
330
331U_NAMESPACE_END
332
333#endif // UCONFIG_NO_IDNA
334
335#endif /* U_SHOW_CPLUSPLUS_API */
336
337#endif // __IDNA_H__
C++ API: Interface for writing bytes, and implementation classes.
A ByteSink can be filled with bytes.
Definition bytestream.h:55
Output container for IDNA processing errors.
Definition idna.h:277
uint32_t getErrors() const
Returns a bit set indicating IDNA processing errors.
Definition idna.h:296
UBool hasErrors() const
Were there IDNA processing errors?
Definition idna.h:289
UBool isTransitionalDifferent() const
Returns true if transitional and nontransitional processing produce different results.
Definition idna.h:310
IDNAInfo()
Constructor for stack allocation.
Definition idna.h:283
Abstract base class for IDNA processing.
Definition idna.h:52
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:61
UMemory is the common ICU base class.
Definition uobject.h:115
UObject is the common ICU "boilerplate" class.
Definition uobject.h:222
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
C++ API: StringPiece: Read-only byte string wrapper class.
C API: Internationalizing Domain Names in Applications (IDNA).
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
C++ API: Unicode String.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition utypes.h:315