YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
CHRLib 命名空间参考

命名空间

 CharSet
 

struct  ConversionState
 编码转换状态。 更多...
 
class  GUCS2Mapper
 静态编码映射模板及 Unicode 编码特化。 更多...
 
struct  GUCS2Mapper< CharSet::Big5 >
 
struct  GUCS2Mapper< CharSet::GBK >
 
struct  GUCS2Mapper< CharSet::SHIFT_JIS >
 非 Unicode 编码映射模板特化。 更多...
 
struct  GUCS2Mapper< CharSet::UTF_16BE >
 
struct  GUCS2Mapper< CharSet::UTF_16LE >
 
struct  GUCS2Mapper< CharSet::UTF_8 >
 

类型定义

using ucs2_t = char16_t
 UCS-2 字符类型。 更多...
 
using ucs4_t = char32_t
 UCS-4 字符类型。 更多...
 
using ucsint_t = std::char_traits< ucs4_t >::int_type
 UCS 整数类型。 更多...
 

枚举

enum  ConversionResult {
  ConversionResult::OK = 0, ConversionResult::BadState, ConversionResult::BadSource, ConversionResult::Invalid,
  ConversionResult::Unhandled
}
 编码转换结果。 更多...
 

函数

ucs2_t FetchBiCharBE (const char *c_ptr)
 取 c_ptr 指向的大端序双字节字符。 更多...
 
ucs2_t FetchBiCharLE (const char *c_ptr)
 取 c_ptr 指向的小端序双字节字符。 更多...
 
YF_API size_t FetchFixedCharWidth (Encoding)
 取指定固定编码的固定字符宽度。 更多...
 
YF_API size_t FetchMaxCharWidth (Encoding)
 取指定编码的最大字符宽度。 更多...
 
YF_API size_t FetchMaxVariantCharWidth (Encoding)
 取指定变长编码的最大字符宽度。 更多...
 
template<typename _tChar >
yconstfn bool IsASCII (_tChar c)
 判断整数类型字符在 ASCII 字符取值范围内。 更多...
 
template<typename _tChar >
yconstfn char ToASCII (_tChar c)
 任意整数类型字符转换为 ASCII 取值范围兼容的字符。 更多...
 
template<class _tString >
std::basic_string< ucs2_tucsdup (const _tString &str)
 
template<typename _tIn , typename _fConv >
ConversionResult ConvertCharacter (_fConv f, ucs2_t &uc, _tIn &&i, ConversionState &&st)
 
template<typename _tIn , typename _fConv >
ConversionResult ConvertCharacter (_fConv f, _tIn &&i, ConversionState &&st)
 
template<typename _fCodemapTransform >
_fCodemapTransform * FetchMapperPtr (Encoding enc)
 取指定编码映射的转换函数指针。 更多...
 
template<typename _tIn , typename _tState >
bool FillByte (_tIn &i, _tState &st)
 以输入迭代器指向内容填充有效输入迭代器指定的字节。 更多...
 
ConversionResult MBCToUC (ucs2_t &uc, std::FILE *fp, Encoding enc, ConversionState &&st)
 
ConversionResult MBCToUC (const char *&c, Encoding enc, ConversionState &&st)
 
ConversionResult MBCToUC (std::FILE *fp, Encoding enc, ConversionState &&st)
 
size_t UCToMBC (char *d, const ucs2_t &s, Encoding enc)
 
YF_API std::basic_string< ucs2_tucsdup (const char *, Encoding=CS_Default)
 复制多字节字符串为 UCS-2 字符串。 更多...
 
YF_API std::basic_string< ucs2_tucsdup (const ucs2_t *)
 复制 UCS-2 字符串。 更多...
 
YF_API std::basic_string< ucs2_tucsdup (const ucs4_t *)
 复制 UCS-4 字符串为 UCS-2 字符串。 更多...
 
template<class _tDst >
_tDst MakeUCS2LEString (const char *s, Encoding enc=CS_Default)
 复制指定编码的多字节字符串为指定类型的 UCS-2 字符串。 更多...
 
template<class _tDst >
_tDst MakeUCS2LEString (const ucs2_t *s, Encoding=CharSet::ISO_10646_UCS_2)
 复制指定类型的 UCS-2 字符串。 更多...
 
template<class _tDst >
_tDst MakeUCS2LEString (const ucs4_t *s, Encoding=CharSet::ISO_10646_UCS_4)
 复制 UCS-4 字符串为指定类型的 UCS-2 字符串。 更多...
 
template<Encoding , typename... _tParams>
yconstfn ConversionResult UCS2Mapper_Map (_tParams &&...)
 取映射函数。 更多...
 
template<Encoding _vEnc, typename _tDst , typename _tSrc , typename _tState >
yconstfn ConversionResult UCS2Mapper_Map (_tDst &&d, _tSrc &&s, _tState &&st, decltype(&GUCS2Mapper< _vEnc >::template Map< _tDst, _tSrc, _tState >)={})
 
template<Encoding _vEnc, typename _tDst , typename _tSrc >
yconstfn byte UCS2Mapper_InverseMap (_tDst, _tSrc)
 
template<Encoding _vEnc, typename _tDst >
yconstfn byte UCS2Mapper_InverseMap (_tDst &&d, const ucs2_t &s, decltype(&GUCS2Mapper< _vEnc >::template InverseMap< _tDst >)={})
 
template<Encoding _vEnc, typename _tIn , typename _tState >
yconstexpr ConversionResult UCS2Mapper (ucs2_t &uc, _tIn &&i, _tState &&st)
 
template<Encoding _vEnc, typename _tIn , typename _tState >
yconstexpr ConversionResult UCS2Mapper (_tIn &&i, _tState &&st)
 
template<Encoding _vEnc>
byte UCS2Mapper (char *d, const ucs2_t &s)
 

变量

yconstexpr Encoding CS_Default = CharSet::UTF_8
 默认字符编码。 更多...
 
byte * cp17
 动态加载的编码转换表。 更多...
 
byte * cp113
 
byte * cp2026
 
 c
 
 enc
 
std::FILE Encoding
 
std::FILE ConversionState fp
 
YF_API ConversionResult MBCToUC (ucs2_t &, const char *&, Encoding, ConversionState &&={})
 按指定编码和转换状态转换字符串中字符为 UCS-2 字符,返回转换的字节数。 更多...
 
 PDefH (ConversionResult, MBCToUC, ucs2_t &uc, const char *&c, Encoding enc, ConversionState &st) ImplRet(MBCToUC(uc
 
std::FILE ConversionState && PDefH (ConversionResult, MBCToUC, ucs2_t &uc, std::FILE *fp, Encoding enc, ConversionState &st) ImplRet(MBCToUC(uc
 
std::FILE ConversionState
ConversionState && 
PDefH (ConversionResult, MBCToUC, const char *&c, Encoding enc, ConversionState &st) ImplRet(MBCToUC(c
 
 PDefH (ConversionResult, MBCToUC, std::FILE *fp, Encoding enc, ConversionState &st) ImplRet(MBCToUC(fp
 
YF_API size_t MBCSToUCS2 (ucs2_t *, const char *, Encoding=CS_Default)
 按指定编码转换 MBCS 字符串为 UCS-2 字符串,返回转换的串长。 更多...
 
YF_API size_t UCS2ToMBCS (char *, const ucs2_t *, Encoding=CS_Default)
 按指定编码转换 UCS-2 字符串为 MBCS 字符串,返回转换的串长。 更多...
 
YF_API size_t UCS4ToUCS2 (ucs2_t *, const ucs4_t *)
 转换 UCS-4 字符串为 UCS-2 字符串,返回转换的串长。 更多...
 
template<class _tDst , class _tSrc >
_tDst GetMBCSOf (const _tSrc &src, Encoding enc=CS_Default)
 取 UCS-2 字符串转换的指定编码的多字节字符串。 更多...
 
YF_API std::string strdup (const ucs2_t *, Encoding=CS_Default)
 复制 UCS-2 字符串为多字节字符串。 更多...
 
template<class _tString >
std::string strdup (const _tString &str)
 

类型定义说明

using CHRLib::ucs2_t = typedef char16_t

UCS-2 字符类型。

在文件 chrdef.h44 行定义.

using CHRLib::ucs4_t = typedef char32_t

UCS-4 字符类型。

在文件 chrdef.h45 行定义.

using CHRLib::ucsint_t = typedef std::char_traits<ucs4_t>::int_type

UCS 整数类型。

在文件 chrdef.h46 行定义.

枚举类型说明

编码转换结果。

自从
build 273
枚举值
OK 

转换成功。

BadState 

转换状态错误。

BadSource 

源数据不可达(如越界)。

Invalid 

数据校验失败(如不构成代码点的字节序列)。

Unhandled 

未处理(超过被处理的界限)。

在文件 chrmap.h75 行定义.

函数说明

template<typename _tIn , typename _fConv >
ConversionResult CHRLib::ConvertCharacter ( _fConv  f,
ucs2_t &  uc,
_tIn &&  i,
ConversionState &&  st 
)

在文件 Convert.hpp40 行定义.

参考 YSLib::UI::f.

参考自 YSLib::Text::TextFileBuffer::GetIterator(), YSLib::Text::TextFileBuffer::GetPosition(), MBCSToUCS2() , 以及 MBCToUC().

这是这个函数的调用关系图:

template<typename _tIn , typename _fConv >
ConversionResult CHRLib::ConvertCharacter ( _fConv  f,
_tIn &&  i,
ConversionState &&  st 
)

在文件 Convert.hpp47 行定义.

参考 YSLib::UI::f.

ucs2_t CHRLib::FetchBiCharBE ( const char *  c_ptr)
inline

取 c_ptr 指向的大端序双字节字符。

前置条件
断言: c_ptr

在文件 chrmap.h53 行定义.

参考 yconstraint.

ucs2_t CHRLib::FetchBiCharLE ( const char *  c_ptr)
inline

取 c_ptr 指向的小端序双字节字符。

前置条件
断言: c_ptr

在文件 chrmap.h64 行定义.

参考 yconstraint.

size_t CHRLib::FetchFixedCharWidth ( Encoding  cp)

取指定固定编码的固定字符宽度。

返回
未定义编码或变长编码返回 0 ,否则为指定编码中每个字符占用的字节数。
注解
UTF-16 视为 UCS-2 。
自从
build 273

在文件 chrmap.cpp37 行定义.

参考 CHRLib::CharSet::csASCII, CHRLib::CharSet::csUCS4, CHRLib::CharSet::csUnicode, CHRLib::CharSet::csUTF16, CHRLib::CharSet::csUTF16BE, CHRLib::CharSet::csUTF16LE, CHRLib::CharSet::csUTF32, CHRLib::CharSet::csUTF32BE , 以及 CHRLib::CharSet::csUTF32LE.

参考自 FetchMaxCharWidth().

这是这个函数的调用关系图:

template<typename _fCodemapTransform >
_fCodemapTransform* CHRLib::FetchMapperPtr ( Encoding  enc)

取指定编码映射的转换函数指针。

自从
build 291

在文件 MapEx.h217 行定义.

参考 CHRLib::CharSet::Big5(), CHR_MapItem, CHRLib::CharSet::GBK(), CHRLib::CharSet::SHIFT_JIS(), CHRLib::CharSet::UTF_16BE(), CHRLib::CharSet::UTF_16LE() , 以及 CHRLib::CharSet::UTF_8().

参考自 MBCSToUCS2(), MBCToUC(), UCS2ToMBCS() , 以及 UCToMBC().

函数调用图:

这是这个函数的调用关系图:

size_t CHRLib::FetchMaxCharWidth ( Encoding  cp)

取指定编码的最大字符宽度。

返回
未定义编码返回 0 ,否则为指定编码中每个字符最大可能占用的字节数。
注解
UTF-16 视为 UCS-2 。
自从
build 273

在文件 chrmap.cpp59 行定义.

参考 FetchFixedCharWidth(), FetchMaxVariantCharWidth() , 以及 YSLib::Drawing::r.

函数调用图:

size_t CHRLib::FetchMaxVariantCharWidth ( Encoding  cp)

取指定变长编码的最大字符宽度。

返回
未定义编码或固定编码返回 0 ,否则为指定编码中每个字符最大可能占用的字节数。
注解
UTF-16 视为 UCS-2 。
自从
build 273

在文件 chrmap.cpp67 行定义.

参考 CHRLib::CharSet::csGB18030, CHRLib::CharSet::csGBK , 以及 CHRLib::CharSet::csUTF8.

参考自 FetchMaxCharWidth().

这是这个函数的调用关系图:

template<typename _tIn , typename _tState >
bool CHRLib::FillByte ( _tIn &  i,
_tState &  st 
)
inline

以输入迭代器指向内容填充有效输入迭代器指定的字节。

自从
build 273

在文件 smap.hpp45 行定义.

参考 ystdex::is_undereferenceable(), YSLib::Drawing::r, YB_UNLIKELY , 以及 yunseq.

参考自 CHRLib::GUCS2Mapper< CharSet::UTF_8 >::Map(), CHRLib::GUCS2Mapper< CharSet::GBK >::Map(), CHRLib::GUCS2Mapper< CharSet::UTF_16BE >::Map() , 以及 CHRLib::GUCS2Mapper< CharSet::UTF_16LE >::Map().

函数调用图:

这是这个函数的调用关系图:

template<class _tDst , class _tSrc >
_tDst CHRLib::GetMBCSOf ( const _tSrc &  src,
Encoding  enc = CS_Default 
)

取 UCS-2 字符串转换的指定编码的多字节字符串。

自从
build 305

在文件 chrproc.h150 行定义.

参考 enc , 以及 UCS2ToMBCS().

函数调用图:

template<typename _tChar >
yconstfn bool CHRLib::IsASCII ( _tChar  c)

判断整数类型字符在 ASCII 字符取值范围内。

注解
截取低 7 位。

在文件 chrproc.h48 行定义.

template<class _tDst >
_tDst CHRLib::MakeUCS2LEString ( const char *  s,
Encoding  enc = CS_Default 
)

复制指定编码的多字节字符串为指定类型的 UCS-2 字符串。

自从
build 402

在文件 chrproc.h208 行定义.

参考 enc, MBCSToUCS2() , 以及 yconstraint.

函数调用图:

template<class _tDst >
_tDst CHRLib::MakeUCS2LEString ( const ucs2_t *  s,
Encoding  = CharSet::ISO_10646_UCS_2 
)

复制指定类型的 UCS-2 字符串。

在文件 chrproc.h221 行定义.

参考 yconstraint.

template<class _tDst >
_tDst CHRLib::MakeUCS2LEString ( const ucs4_t *  s,
Encoding  = CharSet::ISO_10646_UCS_4 
)

复制 UCS-4 字符串为指定类型的 UCS-2 字符串。

在文件 chrproc.h235 行定义.

参考 UCS4ToUCS2() , 以及 yconstraint.

函数调用图:

size_t CHRLib::MBCSToUCS2 ( ucs2_t *  d,
const char *  s,
Encoding  enc = CS_Default 
)

按指定编码转换 MBCS 字符串为 UCS-2 字符串,返回转换的串长。

注解
编码字节序同实现的 ucs2_t 存储字节序。
前置条件
断言: 指针参数非空 。
自从
build 291

在文件 chrproc.cpp112 行定义.

参考 ConvertCharacter(), FetchMapperPtr(), ystdex::is_null() , 以及 yconstraint.

参考自 MakeUCS2LEString(), platform::u16getcwd_n() , 以及 ucsdup().

函数调用图:

这是这个函数的调用关系图:

ConversionResult CHRLib::MBCToUC ( ucs2_t &  uc,
std::FILE *  fp,
Encoding  enc,
ConversionState &&  st 
)

在文件 chrproc.cpp60 行定义.

参考 ConvertCharacter(), FetchMapperPtr(), YSLib::Drawing::r, Unhandled , 以及 yconstraint.

函数调用图:

ConversionResult CHRLib::MBCToUC ( ucs2_t &  uc,
const char *&  c,
Encoding  enc,
ConversionState &&  st = {} 
)

按指定编码和转换状态转换字符串中字符为 UCS-2 字符,返回转换的字节数。

自从
build 291

在文件 chrproc.cpp52 行定义.

参考 ConvertCharacter(), FetchMapperPtr() , 以及 Unhandled.

参考自 YSLib::TextFile::ReadChar() , 以及 YSLib::TextFile::SkipChar().

函数调用图:

这是这个函数的调用关系图:

ConversionResult CHRLib::MBCToUC ( const char *&  c,
Encoding  enc,
ConversionState &&  st 
)

在文件 chrproc.cpp75 行定义.

参考 ConvertCharacter(), FetchMapperPtr() , 以及 Unhandled.

函数调用图:

ConversionResult CHRLib::MBCToUC ( std::FILE *  fp,
Encoding  enc,
ConversionState &&  st 
)

在文件 chrproc.cpp83 行定义.

参考 ConvertCharacter(), FetchMapperPtr(), YSLib::Drawing::r, Unhandled , 以及 yconstraint.

函数调用图:

CHRLib::PDefH ( ConversionResult  ,
MBCToUC  ,
ucs2_t &  uc,
const char *&  c,
Encoding  enc,
ConversionState &  st 
)
inline
std::FILE ConversionState&& CHRLib::PDefH ( ConversionResult  ,
MBCToUC  ,
ucs2_t &  uc,
std::FILE *  fp,
Encoding  enc,
ConversionState &  st 
)
inline
std::FILE ConversionState ConversionState&& CHRLib::PDefH ( ConversionResult  ,
MBCToUC  ,
const char *&  c,
Encoding  enc,
ConversionState &  st 
)
inline
CHRLib::PDefH ( ConversionResult  ,
MBCToUC  ,
std::FILE *  fp,
Encoding  enc,
ConversionState &  st 
)
inline
std::string CHRLib::strdup ( const ucs2_t *  s,
Encoding  enc = CS_Default 
)

复制 UCS-2 字符串为多字节字符串。

前置条件
输入字符串最大多字节不超过 sizeof(ucsint_t) 字节。
自从
build 475
前置条件
断言: 指针参数非空 。

在文件 chrproc.cpp162 行定义.

参考 ystdex::make_unique(), ystdex::ntctslen(), UCS2ToMBCS() , 以及 yconstraint.

参考自 YSLib::IO::EnsureDirectory(), platform::HDirectory::GetName(), strdup(), platform::ufopen() , 以及 platform::uopen().

函数调用图:

这是这个函数的调用关系图:

template<class _tString >
std::string CHRLib::strdup ( const _tString &  str)

在文件 chrproc.h173 行定义.

参考 strdup().

函数调用图:

template<typename _tChar >
yconstfn char CHRLib::ToASCII ( _tChar  c)

任意整数类型字符转换为 ASCII 取值范围兼容的字符。

注解
截取低 7 位。

在文件 chrproc.h59 行定义.

template<Encoding _vEnc, typename _tIn , typename _tState >
yconstexpr ConversionResult CHRLib::UCS2Mapper ( ucs2_t &  uc,
_tIn &&  i,
_tState &&  st 
)

在文件 smap.hpp266 行定义.

template<Encoding _vEnc, typename _tIn , typename _tState >
yconstexpr ConversionResult CHRLib::UCS2Mapper ( _tIn &&  i,
_tState &&  st 
)

在文件 smap.hpp272 行定义.

template<Encoding _vEnc>
byte CHRLib::UCS2Mapper ( char *  d,
const ucs2_t &  s 
)

在文件 smap.hpp278 行定义.

参考 platform_ex::Windows::s , 以及 yconstraint.

template<Encoding _vEnc, typename _tDst , typename _tSrc >
yconstfn byte CHRLib::UCS2Mapper_InverseMap ( _tDst  ,
_tSrc   
)

在文件 smap.hpp251 行定义.

template<Encoding _vEnc, typename _tDst >
yconstfn byte CHRLib::UCS2Mapper_InverseMap ( _tDst &&  d,
const ucs2_t &  s,
decltype &<>::<>  _tDst = {} 
)

在文件 smap.hpp257 行定义.

template<Encoding , typename... _tParams>
yconstfn ConversionResult CHRLib::UCS2Mapper_Map ( _tParams &&  ...)

取映射函数。

自从
build 273

在文件 smap.hpp237 行定义.

参考 Unhandled.

template<Encoding _vEnc, typename _tDst , typename _tSrc , typename _tState >
yconstfn ConversionResult CHRLib::UCS2Mapper_Map ( _tDst &&  d,
_tSrc &&  s,
_tState &&  st,
decltype(&GUCS2Mapper< _vEnc >::template Map< _tDst, _tSrc, _tState >)  = {} 
)

在文件 smap.hpp243 行定义.

size_t CHRLib::UCS2ToMBCS ( char *  d,
const ucs2_t *  s,
Encoding  enc = CS_Default 
)

按指定编码转换 UCS-2 字符串为 MBCS 字符串,返回转换的串长。

前置条件
断言: 指针参数非空 。
自从
build 291

在文件 chrproc.cpp132 行定义.

参考 FetchMapperPtr(), ystdex::is_null() , 以及 yconstraint.

参考自 GetMBCSOf() , 以及 strdup().

函数调用图:

这是这个函数的调用关系图:

size_t CHRLib::UCS4ToUCS2 ( ucs2_t *  d,
const ucs4_t *  s 
)

转换 UCS-4 字符串为 UCS-2 字符串,返回转换的串长。

前置条件
断言: 指针参数非空 。

在文件 chrproc.cpp147 行定义.

参考 ystdex::is_null() , 以及 yconstraint.

参考自 MakeUCS2LEString() , 以及 ucsdup().

函数调用图:

这是这个函数的调用关系图:

std::basic_string< ucs2_t > CHRLib::ucsdup ( const char *  s,
Encoding  enc = CS_Default 
)

复制多字节字符串为 UCS-2 字符串。

自从
build 475
前置条件
断言: 指针参数非空 。

在文件 chrproc.cpp174 行定义.

参考 ystdex::make_unique(), MBCSToUCS2(), ystdex::ntctslen() , 以及 yconstraint.

参考自 ucsdup().

函数调用图:

这是这个函数的调用关系图:

std::basic_string< ucs2_t > CHRLib::ucsdup ( const ucs2_t *  s)

复制 UCS-2 字符串。

在文件 chrproc.cpp184 行定义.

参考 ystdex::make_unique(), ystdex::ntctslen() , 以及 yconstraint.

函数调用图:

std::basic_string< ucs2_t > CHRLib::ucsdup ( const ucs4_t *  s)

复制 UCS-4 字符串为 UCS-2 字符串。

在文件 chrproc.cpp195 行定义.

参考 ystdex::make_unique(), ystdex::ntctslen(), UCS4ToUCS2() , 以及 yconstraint.

函数调用图:

template<class _tString >
std::basic_string<ucs2_t> CHRLib::ucsdup ( const _tString &  str)

在文件 chrproc.h195 行定义.

参考 ucsdup().

函数调用图:

size_t CHRLib::UCToMBC ( char *  d,
const ucs2_t &  s,
Encoding  enc 
)

在文件 chrproc.cpp99 行定义.

参考 FetchMapperPtr(), platform_ex::Windows::l , 以及 yconstraint.

函数调用图:

变量说明

byte * CHRLib::cp113

在文件 MapEx.cpp39 行定义.

参考自 CHRLib::GUCS2Mapper< CharSet::GBK >::Map().

byte * CHRLib::cp17

动态加载的编码转换表。

警告
使用转换映射算法前必须保证非空初始化,否则会断言失败或引起未定义行为。
无线程安全保护。
自从
build 324

在文件 MapEx.cpp38 行定义.

byte * CHRLib::cp2026

在文件 MapEx.cpp40 行定义.

yconstexpr Encoding CHRLib::CS_Default = CharSet::UTF_8

默认字符编码。

自从
build 287

在文件 chrmap.h45 行定义.

std::FILE ConversionState ConversionState CHRLib::enc

在文件 chrproc.h76 行定义.

参考自 GetMBCSOf(), MakeUCS2LEString() , 以及 YReader::ShlTextReader::Switch().

在文件 chrproc.h85 行定义.

std::FILE ConversionState CHRLib::fp

在文件 chrproc.h88 行定义.

参考自 ystdex::fexists() , 以及 platform::truncate().