platform windows support output utf8 text to console

This commit is contained in:
lixianjing 2023-08-21 11:35:50 +08:00
parent 9b30e73519
commit 2ec126c504
2 changed files with 14 additions and 1 deletions

View File

@ -6,6 +6,7 @@
* 增加函数tk\_to\_utf8\_argv
* 增加函数tk\_free\_utf8\_argv
* 增加宏MAIN/END\_MAIN
* 完善Windows平台初始化让Console输出支持UTF8。
2023/08/16
* 增加函数str\_equal/wstr\_eq/wstr\_create/wstr\_destroy/wstr\_append\_more等函数

View File

@ -51,7 +51,6 @@ static int32_t get_local_timezone() {
return timezone;
}
int gettimeofday(struct timeval* tp, void* tzp) {
time_t clock;
struct tm tm;
@ -254,6 +253,19 @@ ret_t platform_prepare(void) {
stm_time_init();
#ifdef WIN32
/*let console output support utf8 text*/
if (!IsValidCodePage(CP_UTF8)) {
log_debug("Not support UTF-8 output\n");
}
if (!SetConsoleCP(CP_UTF8)) {
log_debug("Not support UTF-8 output\n");
}
if (!SetConsoleOutputCP(CP_UTF8)) {
log_debug("Not support UTF-8 output\n");
}
#endif /*WIN32*/
#ifndef HAS_STD_MALLOC
#ifndef TK_HEAP_MEM_SIZE
#define TK_HEAP_MEM_SIZE 12 * 1024 * 1024