added get_utf16_length/to_utf16 functions.

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2022-06-14 15:55:42 +08:00
parent 1874288c2a
commit 22267b5f6f
2 changed files with 27 additions and 3 deletions

View File

@ -17,6 +17,7 @@ namespace hgl
{
HGL_CODE_PAGE_AND_CHAR_SET(NONE, "us-ascii" ),
HGL_CODE_PAGE_AND_CHAR_SET(IBM437, "IBM437" ),
HGL_CODE_PAGE_AND_CHAR_SET(GBK, "gbk" ),
HGL_CODE_PAGE_AND_CHAR_SET(Big5, "big5" ),
@ -70,6 +71,7 @@ namespace hgl
constexpr struct CodePageAndCharSet CodeSet2CharPage[]=
{
HGL_CODE_PAGE_AND_CHAR_SET(NONE, "us-ascii" ),
HGL_CODE_PAGE_AND_CHAR_SET(IBM437, "IBM437" ),
HGL_CODE_PAGE_AND_CHAR_SET(GBK, "gbk" ),
@ -185,16 +187,36 @@ namespace hgl
#else
#define OSCharSet UTF8CharSet
#endif//
/**
* 使 u16char *
* utf16字符串后的长度
* @param charset
* @param dst u16char *delete[]
* @param src
* @param src_size ,-1
* @return
*/
int get_utf16_length(const CharSet &charset,const void *src,const int src_size=-1);
/**
* 使utf16字符串
* @param charset
* @param dst utf16字符串缓冲区delete[]
* @param src
* @param src_size ,-1
* @return
*/
int to_utf16(const CharSet &charset,u16char **dst,const void *src,const int src_size=-1);
/**
* 使utf16字符串
* @param charset
* @param dst utf16字符串缓冲区
* @param dst_size
* @param src
* @param src_size ,-1
* @return
*/
int to_utf16(const CharSet &charset,u16char *dst,const int dst_size,const void *src,const int src_size=-1);
int to_utf8(const CharSet &charset,u8char **dst,const void *src,const int src_size=-1);

View File

@ -16,6 +16,8 @@ namespace hgl
{
NONE=0, ///<起始定义,无意义
IBM437 =437, ///<OEM United States (dos)
//中文
GBK =936, ///<中国GBK标准中文
Big5 =950, ///<中国台湾Big5标准繁体中文