From cdd9d4eb14f4c7f852362f59c14d680f39370685 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 7 Jul 2020 19:15:12 +0800 Subject: [PATCH] support "u8char" type --- src/Win/CodePage.cpp | 12 ++++++------ src/Win/LogConsole.cpp | 2 +- src/Win/LogDialog.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Win/CodePage.cpp b/src/Win/CodePage.cpp index 2c3f85d..5d5612a 100644 --- a/src/Win/CodePage.cpp +++ b/src/Win/CodePage.cpp @@ -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); diff --git a/src/Win/LogConsole.cpp b/src/Win/LogConsole.cpp index 9f20554..690aa86 100644 --- a/src/Win/LogConsole.cpp +++ b/src/Win/LogConsole.cpp @@ -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); diff --git a/src/Win/LogDialog.cpp b/src/Win/LogDialog.cpp index 866a22a..cc24bde 100644 --- a/src/Win/LogDialog.cpp +++ b/src/Win/LogDialog.cpp @@ -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);