News for hackers. Stuff that matters.
Re:UTF-8 – "The most elegant hack" by asveikau on Sunday September 29, 2013 @01:22AM (#6464219)
> You need two versions of functions.

For Windows this is entirely a compatibility thing. One could imagine a world in which that was not strictly necessary. A good best practice for a Win32 app is to always use 16-bit strings when calling system APIs and pretend the "ANSI" versions don't exist; I would not recommend anything else.

In NT the 8-bit versions generally do nothing but convert to 16-bit and call the "real" function. In recent versions (I think Win7 was the first to do this), AFAIK the 8-bit shims typically exist in another module, so if you don't use them they don't get loaded. In NT on ARM the 8-bit shims are not even there.

> It doubles the space for things like storing identifiers for programming languages

Which is why GetProcAddress() still takes an 8-bit string. Just because the kernel (and hence the syscall interface) uses 16-bit everywhere doesn't mean you can't use 8-bit strings in your own process, or that you can't selectively pick what makes sense for your use.

(By the way, none of what I'm saying is a criticism of UTF-8. I think it's a very clever encoding.)

Re:UTF-8 – "The most elegant hack" by option_greek on Sunday September 29, 2013 @03:52AM (#6464475)
If they were using UTF-8, wouldn't just one version of function suffice ? That is, instead of using a shim, just determine which version to call based on the encoding.
Re:UTF-8 – "The most elegant hack" by nitrogen on Sunday September 29, 2013 @04:16AM (#6464518)
There would be no need for the 16-bit versions if they had used UTF-8. The same function signatures would work for ASCII, ISO-8859, or UTF-8.
Re:UTF-8 – "The most elegant hack" by asveikau on Sunday September 29, 2013 @08:01AM (#6464926)
NT development began before UTF-8 existed. Surely you're not suggesting that the authors should have used an encoding that did not yet exist?