Ansi vs Unicode API
Denis Koroskin
2korden at gmail.com
Mon Nov 16 00:41:16 PST 2009
I'd like to raise 2 issues for a discussion.
First, Phobos makes calls to different functions, based on the OS we are
running on (e.g. CreateFileA vs. CreateFileW) and I wonder if it's
*really* necessary, since Microsoft has a Unicode Layer for those
Operating Systems.
All an application needs to do to call W API on those OS'es is link with
unicows.lib (which could be a part of Phobos). It does nothing on Win2k+
and only triggers on 9x OS family.
A very good overview of it is written here:
http://msdn.microsoft.com/en-us/goglobal/bb688166.aspx
Second, "A" API accepts ansi strings as parameters, not UTF-8 strings. I
think this should be reflected in the function signatures, since D
encourages distinguishing between UTF-8 and ANSI strings and not store the
latter as char[].
LPCSTR currently resolves to char*/const(char)*, but it could be better
for it to be an alias to ubyte*/const(ubyte)* so that user couldn't pass
unicode string to an API that doesn't expect one. The same is applicable
to other APIs, too, for example, how does C stdlib co-operate with
Unicode? I.e. is core.stdc.stdio.fopen() unicode-aware?
What are your thoughts on the subject?
More information about the Digitalmars-d
mailing list