Code to get all environment variables
Deewiant
deewiant.doesnotlike.spam at gmail.com
Wed Jun 14 02:05:29 PDT 2006
Thomas Kuehne wrote:
> Are you sure that GetEnvironmentStringsA and FreeEnvironmentStringsA use ASCII?
> I'd expect them to use locale and/or installation dependent ANSI encoding.
>
> Unless there any strong reasons - like buggy implementations in some MSWindows
> versions - I'd opt for the UTF-16 to UTF-8 conversion.
>
> Thoms
>
It seems you're right, they do. *sigh*
Hence, replace the *A functions with *W, change "char" to "wchar" in everything
but the declaration of "arr", and use toUTF8() in the last line of the loop,
like so:
arr[toUTF8(key)] = toUTF8(value);
And thus, of course, import std.utf.
The only problem now is that Windows 95/98/ME require the "Microsoft Layer for
Unicode" - some sort of OS patch, I gather - for the UTF-16 versions of the
functions to work.
I'm not familiar enough with the Windows SDK to know whether there's an easy way
to convert from "whatever encoding the ANSI versions of the functions return" to
the UTF-16 form easily, so my suggestion to users of those OSs is to just go and
update their systems.
More information about the Digitalmars-d-announce
mailing list