|
ICU 51.2
51.2
|
00001 /* 00002 ******************************************************************************* 00003 * Copyright (C) 2010-2012, International Business Machines 00004 * Corporation and others. All Rights Reserved. 00005 ******************************************************************************* 00006 * file name: idna.h 00007 * encoding: US-ASCII 00008 * tab size: 8 (not used) 00009 * indentation:4 00010 * 00011 * created on: 2010mar05 00012 * created by: Markus W. Scherer 00013 */ 00014 00015 #ifndef __IDNA_H__ 00016 #define __IDNA_H__ 00017 00023 #include "unicode/utypes.h" 00024 00025 #if !UCONFIG_NO_IDNA 00026 00027 #include "unicode/bytestream.h" 00028 #include "unicode/stringpiece.h" 00029 #include "unicode/uidna.h" 00030 #include "unicode/unistr.h" 00031 00032 U_NAMESPACE_BEGIN 00033 00034 class IDNAInfo; 00035 00048 class U_COMMON_API IDNA : public UObject { 00049 public: 00054 ~IDNA(); 00055 00089 static IDNA * 00090 createUTS46Instance(uint32_t options, UErrorCode &errorCode); 00091 00112 virtual UnicodeString & 00113 labelToASCII(const UnicodeString &label, UnicodeString &dest, 00114 IDNAInfo &info, UErrorCode &errorCode) const = 0; 00115 00134 virtual UnicodeString & 00135 labelToUnicode(const UnicodeString &label, UnicodeString &dest, 00136 IDNAInfo &info, UErrorCode &errorCode) const = 0; 00137 00158 virtual UnicodeString & 00159 nameToASCII(const UnicodeString &name, UnicodeString &dest, 00160 IDNAInfo &info, UErrorCode &errorCode) const = 0; 00161 00180 virtual UnicodeString & 00181 nameToUnicode(const UnicodeString &name, UnicodeString &dest, 00182 IDNAInfo &info, UErrorCode &errorCode) const = 0; 00183 00184 // UTF-8 versions of the processing methods ---------------------------- *** 00185 00200 virtual void 00201 labelToASCII_UTF8(const StringPiece &label, ByteSink &dest, 00202 IDNAInfo &info, UErrorCode &errorCode) const; 00203 00218 virtual void 00219 labelToUnicodeUTF8(const StringPiece &label, ByteSink &dest, 00220 IDNAInfo &info, UErrorCode &errorCode) const; 00221 00236 virtual void 00237 nameToASCII_UTF8(const StringPiece &name, ByteSink &dest, 00238 IDNAInfo &info, UErrorCode &errorCode) const; 00239 00254 virtual void 00255 nameToUnicodeUTF8(const StringPiece &name, ByteSink &dest, 00256 IDNAInfo &info, UErrorCode &errorCode) const; 00257 }; 00258 00259 class UTS46; 00260 00266 class U_COMMON_API IDNAInfo : public UMemory { 00267 public: 00272 IDNAInfo() : errors(0), labelErrors(0), isTransDiff(FALSE), isBiDi(FALSE), isOkBiDi(TRUE) {} 00278 UBool hasErrors() const { return errors!=0; } 00285 uint32_t getErrors() const { return errors; } 00299 UBool isTransitionalDifferent() const { return isTransDiff; } 00300 00301 private: 00302 friend class UTS46; 00303 00304 IDNAInfo(const IDNAInfo &other); // no copying 00305 IDNAInfo &operator=(const IDNAInfo &other); // no copying 00306 00307 void reset() { 00308 errors=labelErrors=0; 00309 isTransDiff=FALSE; 00310 isBiDi=FALSE; 00311 isOkBiDi=TRUE; 00312 } 00313 00314 uint32_t errors, labelErrors; 00315 UBool isTransDiff; 00316 UBool isBiDi; 00317 UBool isOkBiDi; 00318 }; 00319 00320 U_NAMESPACE_END 00321 00322 #endif // UCONFIG_NO_IDNA 00323 #endif // __IDNA_H__
1.7.6.1