Add UTF-8 codepage support

This commit is contained in:
bumbread 2022-07-31 05:06:15 +11:00
parent 02c0040989
commit b90d7119d4
6 changed files with 28 additions and 11 deletions

3
.gitmodules vendored
View File

@ -4,3 +4,6 @@
[submodule "fdec64"] [submodule "fdec64"]
path = src/fdec64 path = src/fdec64
url = https://github.com/bumbread/fdec64.git url = https://github.com/bumbread/fdec64.git
[submodule "src/libwinsane"]
path = src/libwinsane
url = https://github.com/flysand7/libwinsane.git

View File

@ -1 +1 @@
clang test\test_%test%.c -Iinc -g -lkernel32 -lDbghelp -lciabatta.lib clang test\test_%test%.c src\libwinsane\libwinsane.obj -Iinc -g -lkernel32 -lDbghelp -lciabatta.lib

View File

@ -123,6 +123,9 @@ void _setup_io() {
stdin->buffer = (stream_buffer_t){1, _IOLBF, BUFSIZ, in_buf}; stdin->buffer = (stream_buffer_t){1, _IOLBF, BUFSIZ, in_buf};
stdout->buffer = (stream_buffer_t){1, _IOLBF, BUFSIZ, out_buf}; stdout->buffer = (stream_buffer_t){1, _IOLBF, BUFSIZ, out_buf};
stderr->buffer = (stream_buffer_t){1, _IONBF, 0, NULL}; stderr->buffer = (stream_buffer_t){1, _IONBF, 0, NULL};
SetConsoleCP(CP_UTF8); // maybe will work someday
SetConsoleOutputCP(CP_UTF8);
} }
int win_parse_mode( int win_parse_mode(

1
src/libwinsane Submodule

@ -0,0 +1 @@
Subproject commit c22973570de5d75eff0f03a823536e781ebdac4c

View File

@ -1,10 +0,0 @@
#include <stdio.h>
int main(int argc, char **argv) {
for(int i = 0; i != argc; ++i) {
char *arg = argv[i];
printf("% 2d: %s\n", i, arg);
}
return 0;
}

20
test/test_windows_utf8.c Normal file
View File

@ -0,0 +1,20 @@
#include <stdio.h>
#include <Windows.h>
#pragma comment(lib, "user32.lib")
int main(int argc, char **argv) {
// Print args:
printf("Arguments:\n");
for(int i = 0; i != argc; ++i) {
char *arg = argv[i];
printf(" %s\n", arg);
}
// Test UTF-8 support:
printf(u8"Привет, мир!\n");
printf(u8"こんにちくわ世界!\n");
// Try UTF-8 in winapi (doesn't use UTF-8 without manifest)
MessageBoxA(NULL, u8"Успех", u8"Ошибка", MB_OK);
return 0;
}