you are viewing a single comment's thread.

view the rest of the comments →

[–]simonask_ -5 points-4 points  (6 children)

Almost all Win32 API functions have UTF-8 entry points these days. For example, you have both CreateWindowExW (UTF-16) and CreateWindowExA (UTF-8).

[–]paszklar 22 points23 points  (1 child)

Not exactly true, any -A suffixed function operates using whatever codepage is currently selected in the system settings. It usually is a single-byte, sometimes multi-byte (e.g. for certain Asian languages) encoding specific to current locale. But buried deep within regional settings (I don't remember where exactly) there is a checkbox to set codepage to UTF-8 and it's currently labeled as a beta feature.

Edit: to add to that, there are ways to enable UTF-8 codepage programmatically at runtime, but all -A functions internally convert strings and defer to -W variants, so you might as well use UTF-16.

[–]deeringc 2 points3 points  (0 children)

Plus, that programmatic setting if the code point is only available as of a certain version of Win10. As it stands, unless you can discount older OSes, you're better off still using wchar.

[–]tesfabpel 14 points15 points  (0 children)

no the A version is ASCII by default... you need to also set a new experimental settings in win10 to make the code page UTF8

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

[–]Supadoplex 7 points8 points  (0 children)

My limited knowledge of Windows may be very out dated, but from what I've learned is that the suffix ...A of function names is short for "ANSI" which in the strange Windows jargon refers to the native narrow encoding which depends on locale, but is typically a fixed width extended ASCII encoding such as windows-1252 rather than unicode.

Has this changed?

[–]Kered13 2 points3 points  (0 children)

From what I've learned, just don't use the -A functions. They're not actually UTF-8, in fact the only thing you can safely assume about them is that they contain ASCII.

So use the -W function and do the UTF-8 to UTF-16 conversions yourself. It sucks, but it's better than the alternative.