Ansi vs Unicode API
Denis Koroskin
2korden at gmail.com
Mon Nov 16 01:08:31 PST 2009
On Mon, 16 Nov 2009 11:56:24 +0300, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> Denis Koroskin wrote:
>> 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?
>
> I think it's a great idea. Can phobos redistribute the unicows.lib (cute
> name)?
>
> Andrei
A quote, first:
libunicows — provides an MIT-licensed version of only the UNICOWS.LIB
link-library, but still requires the Microsoft-provided UNICOWS.DLL or the
Mozilla OPENCOW.DLL.
opencow (previously MZLU) — reimplements both the DLL and LIB link-library
as MPL 1.1/GPL 2.0/LGPL 2.1, originally for the Mozilla project.
More information about the Digitalmars-d
mailing list