On Mon, 16 Nov 2009 11:56:24 +0300, Andrei Alexandrescu
<[email protected]> 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:
MSLU comes with licensing terms that are highly unfriendly to Open Source
applications: although you can freely distribute unicows.dll with your
application, your licensing terms must meet certain > conditions that no
Open Source license can. Namely, you must forbid further redistribution
and the license must be an EULA accepted by the user either in writing
or using click-through or shrink-wrap mechanism.
To overcome this obstancle, the Mozilla project began reimplementing
similar solution under Open Source terms: Opencow: Open Layer for Unicode
Overall, there are 2 Open Source alternatives available:
1) libunicows (http://libunicows.sourceforge.net/) — provides an
MIT-licensed version of only the UNICOWS.LIB link-library. Still requires
the Microsoft-provided UNICOWS.DLL or the Mozilla OPENCOW.DLL, but has no
redistribution restrictions (since no Microsoft code redistributed)
2) opencow (previously MZLU) (http://opencow.sourceforge.net/) —
reimplements both the DLL and LIB link-library as MPL 1.1/GPL 2.0/LGPL
2.1, originally for the Mozilla project