Getting environment variables?

novice2 sorry at noem.ail
Sun Nov 23 23:22:43 PST 2008


> Under what setups can the drive letter be a non-ASCII character?
any non-english windows have folders, usernames, etc with non-ascii chars, therefore this names presents in environment, registry, file API etc.

>     wchar[] wpath;
>     wpath.length = GetEnvironmentVariableW("HOMEPATH", null, 0);
>     GetEnvironmentVariableW("HOMEPATH", wpath.ptr, wpath.length);

i am afraid that windows API named *W works with UCS2 string.
but D wchar[] is UTF-16. since UCS2 is some sort of subset of UTF-16, then your code above is correct (then lvalue is D wchar[]).
but problems can appear in reverse situation - pass D wchar[] to windows API.

that is why utf strings in D annoy me - because all strings exchange D<->WindowsAPI shoud be passed thru to-utf and from-utf convertion. other programming languages works fine with windows, not required utf-support editors etc. 
sorry for offtopic.


More information about the Digitalmars-d-learn mailing list