phobos/tango on win32: please drop ANSI "support"

Lionello Lunesu lio at lunesu.remove.com
Thu Feb 15 02:44:13 PST 2007


Walter Bright wrote:
> Lionello Lunesu wrote:
>> Walter Bright wrote:
>>> 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.
>>
>> You should either convert the utf8 to the correct code-page for 
>> passing to WhatEverA(..),
> 
> It does convert to the correct code-page. See std.windows.charset.toMBSz().

The problem is that this function is not always called. And because, by 
default, the A-functions are the ones that get aliased to the 'normal 
form', many times the utf8 char[] is passed as if it were 'ansi'.

A quick grep reveals:

std\loader.d [5]
std\windows\registry.d [35]

I know these are easily solvable, but I was just wondering if it was 
worth the trouble.

>> or convert it to utf16 and pass it to WhatEverW(..). The last one is 
>> much easier: a fixed, straightforward conversion (no need to know 
>> about code-pages)
> 
> This just does not work under Win9x, because most of the 'W' functions 
> are not supported. (Also, Win9x internally converts the few 'W' 
> functions it does support right back to 'A'.)

Yes, but it would be done by Windows. Instead of:

if (UseWFuncs)
   WhatEverA( str.toMBSz );
else
   WhatEverW( str.toUTF16z );

You'd do only:

   WhatEverW( str.toUTF16z );

and Windows' unicode layer for Win9x would convert the string back to 
the proper code-page. Hey, which is exactly what's going on in 
std.windows.charset! But at least I don't have to worry about 
"UseWFuncs" in my own code anymore...

>> that also happens to be efficient for Windows 2000 and up.
> 
> Under Windows NT, 2000, and up, the 'W' functions *are* called.

Only is you'd bother to check UseWFuncs. You probably would, but many don't.

>> As for UseWFuncs: I don't like it because the check is done at run-time.
> 
> It has to be done at runtime, because that's the only way to make it 
> work between different Windows versions.

You could provide link-time support only, using version blocks?

>> It's allover the place, practically doubles all Win32 code, not to 
>> mention the imports / obj-size. More importantly, for the reasons 
>> mentioned above, I don't think it's necessary.
> 
> There's no hope for it unless all support for Win9x is dropped.

See previous question.

L.



More information about the Digitalmars-d mailing list