jart / cosmopolitan

build-once run-anywhere c library
ISC License
17.33k stars 595 forks source link

[windows] UTF-8 Console IO #1131

Open codehz opened 3 months ago

codehz commented 3 months ago

updated: I think it is possible to use only SetConsoleCP / SetConsoleOutputCP without embedding the manifest... since all other api is using either Nt version or W version (which use wide string already)

original:

https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page

The problem: without this, many program that output character outside ansi will produce garbage characters (including --strace output)

Yes, it is possible to use Beta: Use Unicode UTF-8 for worldwide language support but many GDI program will break as it doesn't support UTF-8 per process

G4Vi commented 3 months ago

Unicode strace output could also potentially be fixed for all Windows in our support vector by modifying klog to convert to UTF-16 and print using WriteConsoleW when possible instead of WriteFile. If there isn't enough stack space available to convert to UTF-16 it would have to fallback to existing behavior