support "u8char" type

This commit is contained in:
2020-07-07 19:15:12 +08:00
parent 165e95c0d5
commit cdd9d4eb14
3 changed files with 8 additions and 8 deletions

View File

@@ -4,20 +4,20 @@
namespace hgl
{
int to_utf16(const CharSet &cs,u16char **dst,const char *src,const int src_size)
int to_utf16(const CharSet &cs,u16char **dst,const void *src,const int src_size)
{
const int src_str_size=(src_size==-1)?strlen(src):src_size;
const int src_str_size=(src_size==-1)?strlen((char *)src):src_size;
const int len=MultiByteToWideChar(cs.codepage,0,src,src_str_size,0,0);
const int len=MultiByteToWideChar(cs.codepage,0,(char *)src,src_str_size,0,0);
if(len<=0)return(len);
*dst=new u16char[len];
return MultiByteToWideChar(cs.codepage,0,src,src_str_size,*dst,len);
return MultiByteToWideChar(cs.codepage,0,(char *)src,src_str_size,*dst,len);
}
int to_utf8(const CharSet &cs,char **dst,const char *src,const int src_size)
int to_utf8(const CharSet &cs,u8char **dst,const void *src,const int src_size)
{
u16char *u16str;
int u16size=to_utf16(cs,&u16str,src,src_size);
@@ -44,7 +44,7 @@ namespace hgl
return WideCharToMultiByte(cs.codepage,0,src,src_str_size,*dst,len,0,0);
}
int utf8_to(const CharSet &cs,char **dst,const char *src,const int src_size)
int utf8_to(const CharSet &cs,char **dst,const u8char *src,const int src_size)
{
int u16str_size;
u16char *u16str=u8_to_u16(src,src_size,u16str_size);

View File

@@ -46,7 +46,7 @@ namespace hgl
WriteConsoleW(console_handle,L"\n", 1, &result, nullptr);
}
void Write(const char *str,int size)
void Write(const u8char *str,int size)
{
const int len=u8_to_u16(buf,LOG_BUF_SIZE,str,size);

View File

@@ -33,7 +33,7 @@ namespace hgl
MessageBoxW(nullptr,str,name,MB_OK);
}
void Write(const char *str,int size)
void Write(const u8char *str,int size)
{
const int len=u8_to_u16(buf,4096,str,size);