Re:cuneicode, and the Future of Text in C
by dundarious on Wednesday June 07, 2023 @09:48AM
(#36226752)
What about compiling programs with `cl -utf-8` and using -A APIs? I know the docs say “If the ANSI code page is configured for UTF-8, -A APIs typically operate in UTF-8”, to which I say, just “typically”?! But in practice is it not sufficient?
[ Parent
| on HN ]
Re:cuneicode, and the Future of Text in C
by hermitdev on Wednesday June 07, 2023 @10:12AM
(#36227024)
The -A APIs are converted to calls to the -W APIs, IIRC, so you pay that cost everywhere. Not sure if that's universally true anymore, but it has been that way at least on the NT based kernel since...inception? Probably a good question for Raymond Chen. Sadly, I can't seem to find anything relevant in a quick search of the Old New Thing.
Re:cuneicode, and the Future of Text in C
by colejohnson66 on Wednesday June 07, 2023 @01:06PM
(#36229734)
The GP is referencing the new UTF-8 APIs that reuse the -A suffixes.[0]
> Until recently, Windows has emphasized "Unicode" -W variants over -A APIs. However, recent releases have used the ANSI code page and -A APIs as a means to introduce UTF-8 support to apps. If the ANSI code page is configured for UTF-8, -A APIs typically operate in UTF-8. This model has the benefit of supporting existing code built with -A APIs without any code changes.
This requires Windows 10 version 1903 or newer. As the version number suggests, this feature is only four years old, and using them prevents your program from working on older versions.
[0]: https://learn.microsoft.com/en-us/windows/apps/design/global...
Re:cuneicode, and the Future of Text in C
by dundarious on Wednesday June 07, 2023 @02:12PM
(#36230899)
Yes, precisely. I have never tested it conclusively, but (taking it as a given that we are targeting >=1903) is it not sufficient and optimal to use `-utf-8` and -A APIs?
Windows UTF-8 support is relatively recent and I have no experience with it, so I don’t know. However I expect Windows to just do the same conversions internally or in the linked runtime, that the program would otherwise have to do by itself. I’d assume that there will be edge cases that such programs then can’t handle, such as UI input and file paths containing unpaired surrogates.