idna.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) 2010-2012, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
* file name: idna.h
* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
* created on: 2010mar05
* created by: Markus W. Scherer
*/
#ifndef __IDNA_H__
#define __IDNA_H__
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#if !UCONFIG_NO_IDNA
#include "unicode/bytestream.h"
#include "unicode/stringpiece.h"
#include "unicode/uidna.h"
#include "unicode/unistr.h"
U_NAMESPACE_BEGIN
class IDNAInfo;
class U_COMMON_API IDNA : public UObject {
public:
~IDNA();
static IDNA *
createUTS46Instance(uint32_t options, UErrorCode &errorCode);
virtual UnicodeString &
labelToASCII(const UnicodeString &label, UnicodeString &dest,
IDNAInfo &info, UErrorCode &errorCode) const = 0;
virtual UnicodeString &
labelToUnicode(const UnicodeString &label, UnicodeString &dest,
IDNAInfo &info, UErrorCode &errorCode) const = 0;
virtual UnicodeString &
nameToASCII(const UnicodeString &name, UnicodeString &dest,
IDNAInfo &info, UErrorCode &errorCode) const = 0;
virtual UnicodeString &
nameToUnicode(const UnicodeString &name, UnicodeString &dest,
IDNAInfo &info, UErrorCode &errorCode) const = 0;
// UTF-8 versions of the processing methods ---------------------------- ***
virtual void
labelToASCII_UTF8(StringPiece label, ByteSink &dest,
IDNAInfo &info, UErrorCode &errorCode) const;
virtual void
labelToUnicodeUTF8(StringPiece label, ByteSink &dest,
IDNAInfo &info, UErrorCode &errorCode) const;
virtual void
nameToASCII_UTF8(StringPiece name, ByteSink &dest,
IDNAInfo &info, UErrorCode &errorCode) const;
virtual void
nameToUnicodeUTF8(StringPiece name, ByteSink &dest,
IDNAInfo &info, UErrorCode &errorCode) const;
};
class UTS46;
class U_COMMON_API IDNAInfo : public UMemory {
public:
IDNAInfo() : errors(0), labelErrors(0), isTransDiff(false), isBiDi(false), isOkBiDi(true) {}
UBool hasErrors() const { return errors!=0; }
uint32_t getErrors() const { return errors; }
UBool isTransitionalDifferent() const { return isTransDiff; }
private:
friend class UTS46;
IDNAInfo(const IDNAInfo &other) = delete; // no copying
IDNAInfo &operator=(const IDNAInfo &other) = delete; // no copying
void reset() {
errors=labelErrors=0;
isTransDiff=false;
isBiDi=false;
isOkBiDi=true;
}
uint32_t errors, labelErrors;
UBool isTransDiff;
UBool isBiDi;
UBool isOkBiDi;
};
U_NAMESPACE_END
#endif // UCONFIG_NO_IDNA
#endif /* U_SHOW_CPLUSPLUS_API */
#endif // __IDNA_H__
bytestream.h
C++ API: Interface for writing bytes, and implementation classes.
icu::ByteSink
A ByteSink can be filled with bytes.
Definition bytestream.h:53
icu::IDNAInfo
Output container for IDNA processing errors.
Definition idna.h:273
icu::IDNAInfo::getErrors
uint32_t getErrors() const
Returns a bit set indicating IDNA processing errors.
Definition idna.h:292
icu::IDNAInfo::hasErrors
UBool hasErrors() const
Were there IDNA processing errors?
Definition idna.h:285
icu::IDNAInfo::isTransitionalDifferent
UBool isTransitionalDifferent() const
Returns true if transitional and nontransitional processing produce different results.
Definition idna.h:306
icu::IDNAInfo::IDNAInfo
IDNAInfo()
Constructor for stack allocation.
Definition idna.h:279
icu::IDNA
Abstract base class for IDNA processing.
Definition idna.h:52
icu::IDNA::labelToASCII_UTF8
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.
icu::IDNA::nameToASCII_UTF8
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.
icu::IDNA::createUTS46Instance
static IDNA * createUTS46Instance(uint32_t options, UErrorCode &errorCode)
Returns an IDNA instance which implements UTS #46.
icu::IDNA::nameToUnicodeUTF8
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.
icu::IDNA::labelToASCII
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.
icu::IDNA::labelToUnicodeUTF8
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.
icu::IDNA::~IDNA
~IDNA()
Destructor.
icu::IDNA::nameToUnicode
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.
icu::IDNA::nameToASCII
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.
icu::IDNA::labelToUnicode
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.
icu::StringPiece
A string-like object that points to a sized piece of memory.
Definition stringpiece.h:61
icu::UMemory
UMemory is the common ICU base class.
Definition uobject.h:115
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition uobject.h:223
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:296
stringpiece.h
C++ API: StringPiece: Read-only byte string wrapper class.
uidna.h
C API: Internationalizing Domain Names in Applications (IDNA)
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:247
unistr.h
C++ API: Unicode String.
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:430
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:315