RLib  5.7
RLib - an opensource, lightweight and multi-platform framework for cpp programming
System::Text::Encoder Class Reference

提供一组字符编码的转换方法 More...

Static Public Member Functions

static bool IsTextUnicode (_In_ const void *lpv, _In_ intptr_t size)
 Determines if a buffer is likely to contain a form of Unicode text More...
 
static bool IsTextUtf8 (_In_ const void *lpv, _In_ intptr_t size)
 Determines if a buffer is likely to contain a form of Utf-8 text More...
 
static Encoding DetectEncodingFromByteOrderMarks (LPCVOID ptr, OUT intptr_t *lpbytes=nullptr)
 在头部查找字节顺序标记并返回编码方式 More...
 
static bool WriteByteOrderMarks (IO::Stream &stream, Encoding codepage)
 根据指定编码写入字节顺序标记 More...
 
static Encoding GetCurrentEncoding ()
 获取当前默认的字符编码方式 More...
 
static IO::BufferedStreamToCurrentEncoding (LPCVOID lpdata, intptr_t size, Encoding codepage, bool detectEncodingFromByteOrderMarks=true)
 将指定编码方式的数据转换为当前编码格式(UTF-16(_UNICODE编译选项) or GB2312) More...
 
static IO::BufferedStreamToCurrentEncoding (Encoding codepage, const IO::Stream &stream, intptr_t length=-1, bool detectEncodingFromByteOrderMarks=true)
 将指定编码方式的数据流转换为当前编码格式(UTF-16(_UNICODE编译选项) or GB2312) More...
 
static IO::BufferedStreamToWideChar (LPCVOID pdata, intptr_t size, Encoding codepage)
 将指定编码方式的多字节数据流转换为宽字符数据流(any to utf-16) More...
 
static IO::BufferedStreamToWideChar (Encoding codepage, const IO::Stream &stream, intptr_t length=-1)
 将指定编码方式的多字节数据流转换为宽字符数据流(any to utf-16) More...
 
static IO::BufferedStreamWideCharTo (LPCVOID pdata, intptr_t size, Encoding codepage)
 将宽字符数据流转换为指定编码方式的多字节数据流(utf-16 to any) More...
 
static IO::BufferedStreamWideCharTo (Encoding codepage, const IO::Stream &stream, intptr_t length=-1)
 将宽字符数据流转换为指定编码方式的多字节数据流(utf-16 to any) More...
 
static bool WriteTextStream (OUT IO::Stream &outputStream, IN const IO::Stream &textStream, intptr_t bytesToWrite=-1, bool useBOM=true, Text::Encoding codepage=Text::UnknownEncoding)
 以指定编码将文本流写入指定流 More...
 
static bool WriteTextStream (OUT IO::Stream &outputStream, IN LPCVOID textData, intptr_t bytesToWrite, bool useBOM=true, Text::Encoding codepage=Text::UnknownEncoding)
 以指定编码将文本流写入指定流 More...
 

Detailed Description

提供一组字符编码的转换方法

Member Function Documentation

Encoding Encoder::DetectEncodingFromByteOrderMarks ( LPCVOID  ptr,
OUT intptr_t *  lpbytes = nullptr 
)
static

在头部查找字节顺序标记并返回编码方式

Warning
确保传入的缓冲区至少有3个可读字节
Encoding Encoder::GetCurrentEncoding ( )
static

获取当前默认的字符编码方式

bool Encoder::IsTextUnicode ( _In_ const void *  lpv,
_In_ intptr_t  size 
)
static

Determines if a buffer is likely to contain a form of Unicode text

Warning
not supported currently
bool Encoder::IsTextUtf8 ( _In_ const void *  lpv,
_In_ intptr_t  size 
)
static

Determines if a buffer is likely to contain a form of Utf-8 text

BufferedStream * Encoder::ToCurrentEncoding ( LPCVOID  lpdata,
intptr_t  size,
Encoding  codepage,
bool  detectEncodingFromByteOrderMarks = true 
)
static

将指定编码方式的数据转换为当前编码格式(UTF-16(_UNICODE编译选项) or GB2312)

BufferedStream * Encoder::ToCurrentEncoding ( Encoding  codepage,
const IO::Stream stream,
intptr_t  length = -1,
bool  detectEncodingFromByteOrderMarks = true 
)
static

将指定编码方式的数据流转换为当前编码格式(UTF-16(_UNICODE编译选项) or GB2312)

BufferedStream * Encoder::ToWideChar ( LPCVOID  pdata,
intptr_t  size,
Encoding  codepage 
)
static

将指定编码方式的多字节数据流转换为宽字符数据流(any to utf-16)

Returns
返回的数据流必须由用户释放(delete), 且默认Pos = 0
BufferedStream * Encoder::ToWideChar ( Encoding  codepage,
const IO::Stream stream,
intptr_t  length = -1 
)
static

将指定编码方式的多字节数据流转换为宽字符数据流(any to utf-16)

Returns
返回的数据流必须由用户释放(delete), 且默认Pos = 0
BufferedStream * Encoder::WideCharTo ( LPCVOID  pdata,
intptr_t  size,
Encoding  codepage 
)
static

将宽字符数据流转换为指定编码方式的多字节数据流(utf-16 to any)

Returns
返回的数据流必须由用户释放(delete), 且默认Pos = 0
BufferedStream * Encoder::WideCharTo ( Encoding  codepage,
const IO::Stream stream,
intptr_t  length = -1 
)
static

将宽字符数据流转换为指定编码方式的多字节数据流(utf-16 to any)

Returns
返回的数据流必须由用户释放(delete), 且默认Pos = 0
bool Encoder::WriteByteOrderMarks ( IO::Stream stream,
Encoding  codepage 
)
static

根据指定编码写入字节顺序标记

bool Encoder::WriteTextStream ( OUT IO::Stream outputStream,
IN const IO::Stream textStream,
intptr_t  bytesToWrite = -1,
bool  useBOM = true,
Text::Encoding  codepage = Text::UnknownEncoding 
)
static

以指定编码将文本流写入指定流

Parameters
outputStream目标流
textStream源文本流, 编码与编译环境相关
bytesToWrite写入长度, in bytes
useBOM是否包含BOM文件头
codepage输出的编码方式
bool Encoder::WriteTextStream ( OUT IO::Stream outputStream,
IN LPCVOID  textData,
intptr_t  bytesToWrite,
bool  useBOM = true,
Text::Encoding  codepage = Text::UnknownEncoding 
)
static

以指定编码将文本流写入指定流

Parameters
outputStream目标流
textData源文本指针, 编码与编译环境相关
bytesToWrite写入长度, in bytes
useBOM是否包含BOM文件头
codepage输出的编码方式

The documentation for this class was generated from the following files: