phobos/tango on win32: please drop ANSI "support"
Lionello Lunesu
lio at lunesu.remove.com
Thu Feb 15 02:26:55 PST 2007
kris wrote:
> Lionello Lunesu wrote:
>> Walter Bright wrote:
>>
>>> Lionello Lunesu wrote:
>>>
>>>> Both Phobos and Tango pretend utf8 is valid for calling ANSI methods
>>>> from the Windows' API. Obviously, it's not. The correct way is to
>>>> convert the utf8 string to the code-page expected by the call, or
>>>> convert them to unicode.
>>>>
>>>> I'd like to suggest the latter. Let's drop the ANSI support for
>>>> Win32 altogether. Unicode is supported since Windows 95 OSR-2 (if
>>>> I'm not mistaken) and converting utf8 to ANSI is more expensive than
>>>> converting it utf8 to utf16 (which is what Windows 2000 and up
>>>> convert to internally anyway). No more "bool UseWFuncs". And
>>>> converting utf8 to utf16 using MultiByteToWideChar would also take
>>>> care of the 0-terminator.
>>>
>>>
>>> The "useWfuncs" only happens for Windows 9x (including Me). All
>>> Windows 9x systems are 8 bit internally, and even if you use the W
>>> interface, they are internally converted to 8 bits anyway.
>>
>>
>> Yes, they will be converted to "8 bits", but not to utf8. They will be
>> converted to whatever code-page the thread's currently using, which is
>> what's supposed to be done. That's my point: both Phobos and Tango
>> pass utf8 to ANSI (..A) versions of Windows' functions, which is not
>> correct.
>
> Regarding Tango, it uses the WindowsA functions only if
> -verion=Win32SansUnicode is configured. This switch is for supporting
> certain older environments, but does /not/ imply that code-pages are
> supported in Tango. There has never been an intent to do so.
Then it's not actually supporting those older environments at all.
> For code-page support, we currently suggest using a library such as ICU
> to do the appropriate conversions.
On Windows, just convert to wchar[] (as you would on W2K and up) and
then use WideCharToMultiByte.
L.
More information about the Digitalmars-d
mailing list