OpenVPN 3 Core Library
Loading...
Searching...
No Matches
openvpn::Unicode Namespace Reference

Classes

class  UTF8Iterator
 

Typedefs

typedef unsigned int UTF32
 
typedef unsigned short UTF16
 
typedef unsigned char UTF8
 

Enumerations

enum  ConversionResult { conversionOK , sourceExhausted , targetExhausted , sourceIllegal }
 
enum  ConversionFlags { strictConversion = 0 , lenientConversion }
 
enum  { UTF8_NO_CTRL = (1 << 30) , UTF8_NO_SPACE = (1 << 31) }
 
enum  { UTF8_GOOD = 0 , UTF8_BAD , UTF8_RANGE }
 
enum  { UTF8_PASS_FMT = (1 << 31) , UTF8_FILTER = (1 << 30) }
 

Functions

ConversionResult ConvertUTF32toUTF16 (const UTF32 **sourceStart, const UTF32 *sourceEnd, UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags)
 
ConversionResult ConvertUTF16toUTF32 (const UTF16 **sourceStart, const UTF16 *sourceEnd, UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags)
 
ConversionResult ConvertUTF16toUTF8 (const UTF16 **sourceStart, const UTF16 *sourceEnd, UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags)
 
bool isLegalUTF8 (const UTF8 *source, int length)
 
bool isLegalUTF8Sequence (const UTF8 *source, const UTF8 *sourceEnd)
 
ConversionResult ConvertUTF8toUTF16 (const UTF8 **sourceStart, const UTF8 *sourceEnd, UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags)
 
ConversionResult ConvertUTF32toUTF8 (const UTF32 **sourceStart, const UTF32 *sourceEnd, UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags)
 
ConversionResult ConvertUTF8toUTF32 (const UTF8 **sourceStart, const UTF8 *sourceEnd, UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags)
 
 OPENVPN_SIMPLE_EXCEPTION (unicode_src_overflow)
 
 OPENVPN_SIMPLE_EXCEPTION (unicode_dest_overflow)
 
 OPENVPN_SIMPLE_EXCEPTION (unicode_malformed)
 
bool is_valid_utf8_uchar_buf (const unsigned char *source, size_t size, const size_t max_len_flags=0)
 
template<typename STRING >
bool is_valid_utf8 (const STRING &str, const size_t max_len_flags=0)
 
template<typename STRING >
int utf8_index (STRING &str, size_t &index)
 
template<typename STRING >
void utf8_truncate (STRING &str, size_t max_len)
 
template<typename STRING >
STRING utf8_printable (const STRING &str, size_t max_len_flags)
 
template<typename STRING >
size_t utf8_length (const STRING &str)
 
void conversion_result_throw (const ConversionResult res)
 
template<typename STRING >
BufferPtr string_to_utf16 (const STRING &str)
 

Variables

const UTF32 UNI_REPLACEMENT_CHAR = (UTF32)0x0000FFFD
 
const UTF32 UNI_MAX_BMP = (UTF32)0x0000FFFF
 
const UTF32 UNI_MAX_UTF16 = (UTF32)0x0010FFFF
 
const UTF32 UNI_MAX_UTF32 = (UTF32)0x7FFFFFFF
 
const UTF32 UNI_MAX_LEGAL_UTF32 = (UTF32)0x0010FFFF
 
const int halfShift = 10
 
const UTF32 halfBase = 0x0010000UL
 
const UTF32 halfMask = 0x3FFUL
 
const UTF32 UNI_SUR_HIGH_START = (UTF32)0xD800
 
const UTF32 UNI_SUR_HIGH_END = (UTF32)0xDBFF
 
const UTF32 UNI_SUR_LOW_START = (UTF32)0xDC00
 
const UTF32 UNI_SUR_LOW_END = (UTF32)0xDFFF
 
const char trailingBytesForUTF8 [256]
 
const UTF32 offsetsFromUTF8 [6]
 
const UTF8 firstByteMark [7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }
 

Typedef Documentation

◆ UTF16

typedef unsigned short openvpn::Unicode::UTF16

Definition at line 96 of file unicode-impl.hpp.

◆ UTF32

typedef unsigned int openvpn::Unicode::UTF32

Definition at line 95 of file unicode-impl.hpp.

◆ UTF8

typedef unsigned char openvpn::Unicode::UTF8

Definition at line 97 of file unicode-impl.hpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
UTF8_NO_CTRL 
UTF8_NO_SPACE 

Definition at line 36 of file unicode.hpp.

◆ anonymous enum

anonymous enum
Enumerator
UTF8_GOOD 
UTF8_BAD 
UTF8_RANGE 

Definition at line 82 of file unicode.hpp.

◆ anonymous enum

anonymous enum
Enumerator
UTF8_PASS_FMT 
UTF8_FILTER 

Definition at line 123 of file unicode.hpp.

◆ ConversionFlags

Enumerator
strictConversion 
lenientConversion 

Definition at line 113 of file unicode-impl.hpp.

◆ ConversionResult

Enumerator
conversionOK 
sourceExhausted 
targetExhausted 
sourceIllegal 

Definition at line 106 of file unicode-impl.hpp.

Function Documentation

◆ conversion_result_throw()

void openvpn::Unicode::conversion_result_throw ( const ConversionResult  res)
inline

Definition at line 196 of file unicode.hpp.

Here is the caller graph for this function:

◆ ConvertUTF16toUTF32()

ConversionResult openvpn::Unicode::ConvertUTF16toUTF32 ( const UTF16 **  sourceStart,
const UTF16 sourceEnd,
UTF32 **  targetStart,
UTF32 targetEnd,
ConversionFlags  flags 
)
inline

Definition at line 220 of file unicode-impl.hpp.

◆ ConvertUTF16toUTF8()

ConversionResult openvpn::Unicode::ConvertUTF16toUTF8 ( const UTF16 **  sourceStart,
const UTF16 sourceEnd,
UTF8 **  targetStart,
UTF8 targetEnd,
ConversionFlags  flags 
)
inline

Definition at line 324 of file unicode-impl.hpp.

◆ ConvertUTF32toUTF16()

ConversionResult openvpn::Unicode::ConvertUTF32toUTF16 ( const UTF32 **  sourceStart,
const UTF32 sourceEnd,
UTF16 **  targetStart,
UTF16 targetEnd,
ConversionFlags  flags 
)
inline

Definition at line 171 of file unicode-impl.hpp.

◆ ConvertUTF32toUTF8()

ConversionResult openvpn::Unicode::ConvertUTF32toUTF8 ( const UTF32 **  sourceStart,
const UTF32 sourceEnd,
UTF8 **  targetStart,
UTF8 targetEnd,
ConversionFlags  flags 
)
inline

Definition at line 519 of file unicode-impl.hpp.

◆ ConvertUTF8toUTF16()

ConversionResult openvpn::Unicode::ConvertUTF8toUTF16 ( const UTF8 **  sourceStart,
const UTF8 sourceEnd,
UTF16 **  targetStart,
UTF16 targetEnd,
ConversionFlags  flags 
)
inline

Definition at line 446 of file unicode-impl.hpp.

Here is the caller graph for this function:

◆ ConvertUTF8toUTF32()

ConversionResult openvpn::Unicode::ConvertUTF8toUTF32 ( const UTF8 **  sourceStart,
const UTF8 sourceEnd,
UTF32 **  targetStart,
UTF32 targetEnd,
ConversionFlags  flags 
)
inline

Definition at line 572 of file unicode-impl.hpp.

◆ is_valid_utf8()

template<typename STRING >
bool openvpn::Unicode::is_valid_utf8 ( const STRING &  str,
const size_t  max_len_flags = 0 
)
inline

Definition at line 75 of file unicode.hpp.

Here is the caller graph for this function:

◆ is_valid_utf8_uchar_buf()

bool openvpn::Unicode::is_valid_utf8_uchar_buf ( const unsigned char *  source,
size_t  size,
const size_t  max_len_flags = 0 
)
inline

Definition at line 41 of file unicode.hpp.

Here is the caller graph for this function:

◆ isLegalUTF8()

bool openvpn::Unicode::isLegalUTF8 ( const UTF8 source,
int  length 
)
inline

Definition at line 405 of file unicode-impl.hpp.

Here is the caller graph for this function:

◆ isLegalUTF8Sequence()

bool openvpn::Unicode::isLegalUTF8Sequence ( const UTF8 source,
const UTF8 sourceEnd 
)
inline

Definition at line 436 of file unicode-impl.hpp.

◆ OPENVPN_SIMPLE_EXCEPTION() [1/3]

openvpn::Unicode::OPENVPN_SIMPLE_EXCEPTION ( unicode_dest_overflow  )

◆ OPENVPN_SIMPLE_EXCEPTION() [2/3]

openvpn::Unicode::OPENVPN_SIMPLE_EXCEPTION ( unicode_malformed  )

◆ OPENVPN_SIMPLE_EXCEPTION() [3/3]

openvpn::Unicode::OPENVPN_SIMPLE_EXCEPTION ( unicode_src_overflow  )

◆ string_to_utf16()

template<typename STRING >
BufferPtr openvpn::Unicode::string_to_utf16 ( const STRING &  str)
inline

Definition at line 213 of file unicode.hpp.

Here is the caller graph for this function:

◆ utf8_index()

template<typename STRING >
int openvpn::Unicode::utf8_index ( STRING &  str,
size_t &  index 
)
inline

Definition at line 89 of file unicode.hpp.

Here is the caller graph for this function:

◆ utf8_length()

template<typename STRING >
size_t openvpn::Unicode::utf8_length ( const STRING &  str)
inline

Definition at line 179 of file unicode.hpp.

Here is the caller graph for this function:

◆ utf8_printable()

template<typename STRING >
STRING openvpn::Unicode::utf8_printable ( const STRING &  str,
size_t  max_len_flags 
)
inline

Definition at line 129 of file unicode.hpp.

Here is the caller graph for this function:

◆ utf8_truncate()

template<typename STRING >
void openvpn::Unicode::utf8_truncate ( STRING &  str,
size_t  max_len 
)
inline

Definition at line 112 of file unicode.hpp.

Variable Documentation

◆ firstByteMark

const UTF8 openvpn::Unicode::firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }

Definition at line 310 of file unicode-impl.hpp.

◆ halfBase

const UTF32 openvpn::Unicode::halfBase = 0x0010000UL

Definition at line 161 of file unicode-impl.hpp.

◆ halfMask

const UTF32 openvpn::Unicode::halfMask = 0x3FFUL

Definition at line 162 of file unicode-impl.hpp.

◆ halfShift

const int openvpn::Unicode::halfShift = 10

Definition at line 159 of file unicode-impl.hpp.

◆ offsetsFromUTF8

const UTF32 openvpn::Unicode::offsetsFromUTF8[6]
Initial value:
= { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
0x03C82080UL, 0xFA082080UL, 0x82082080UL }

Definition at line 300 of file unicode-impl.hpp.

◆ trailingBytesForUTF8

const char openvpn::Unicode::trailingBytesForUTF8[256]
Initial value:
= {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
}

Definition at line 284 of file unicode-impl.hpp.

◆ UNI_MAX_BMP

const UTF32 openvpn::Unicode::UNI_MAX_BMP = (UTF32)0x0000FFFF

Definition at line 101 of file unicode-impl.hpp.

◆ UNI_MAX_LEGAL_UTF32

const UTF32 openvpn::Unicode::UNI_MAX_LEGAL_UTF32 = (UTF32)0x0010FFFF

Definition at line 104 of file unicode-impl.hpp.

◆ UNI_MAX_UTF16

const UTF32 openvpn::Unicode::UNI_MAX_UTF16 = (UTF32)0x0010FFFF

Definition at line 102 of file unicode-impl.hpp.

◆ UNI_MAX_UTF32

const UTF32 openvpn::Unicode::UNI_MAX_UTF32 = (UTF32)0x7FFFFFFF

Definition at line 103 of file unicode-impl.hpp.

◆ UNI_REPLACEMENT_CHAR

const UTF32 openvpn::Unicode::UNI_REPLACEMENT_CHAR = (UTF32)0x0000FFFD

Definition at line 100 of file unicode-impl.hpp.

◆ UNI_SUR_HIGH_END

const UTF32 openvpn::Unicode::UNI_SUR_HIGH_END = (UTF32)0xDBFF

Definition at line 165 of file unicode-impl.hpp.

◆ UNI_SUR_HIGH_START

const UTF32 openvpn::Unicode::UNI_SUR_HIGH_START = (UTF32)0xD800

Definition at line 164 of file unicode-impl.hpp.

◆ UNI_SUR_LOW_END

const UTF32 openvpn::Unicode::UNI_SUR_LOW_END = (UTF32)0xDFFF

Definition at line 167 of file unicode-impl.hpp.

◆ UNI_SUR_LOW_START

const UTF32 openvpn::Unicode::UNI_SUR_LOW_START = (UTF32)0xDC00

Definition at line 166 of file unicode-impl.hpp.