locales, unicode and ansi with msvcrt (bug 8022)

Kirill K. Smirnov lich at math.spbu.ru
Wed Apr 18 12:24:55 CDT 2007

Hi Jason,

While preparing tests I found the 'user' backend of wineconsole works with 
WriteConsole/WriteFile correct (see test1 and test2), so I used it as etal.

I figured out the main issue with cmd:
It passes strings to WriteFile in ANSI, but should in OEM.

I think the main locale issue is found. CMD and XCOPY violate this.
So it is not MSVCRT bug. Moreover, [w]fprintf MUST NOT perform any AnsiToOem 
convertions (as test3 and test4 show).

I made and attached a quick hack to demostrate that cmd was buggy. Attached 
screenshots show the difference. The patch heals almost everything, even 
localized filenames. So I'm CC'ing mail to wine-devel, console/cmd gurus must 
know much more ;-)

I found some issues with wprintf, see README for test3 and test4.
The attached tests are made with your patch applied.

What about running cmd without console, I think it is not a good idea -  we 
must check locale and enconding, thus we must perform various convertions: to 
utf8, to cp1251, to koi8-r... Or just we must set correct value of 
console_[input|output]_codepage variables? Does windows console supports UTF8 
as output codepage?

> Given I don't know russian, is there any chance of writing me a short
> program which uses _wfopen, fwprintf, fclose to create me a file with a
> name and contents which are russian text, so I can test some of the cmd.exe
> issues reported with NLS chars.

> Could I also have:
> 1. Output from 'chcp' in a windows command prompt
"Текущая кодовая страница: 866"
["Current codepage: 866"]

> 2. screen shot of 'dir' in a windows command prompt after running the
> program so I know what characters I am expecting
> 3. Details of the LANG env var, and details of the xterm (I run Mandrake,
> and have Settings->Font and Settings->Encoding options which seem like the
> way to tailor what appears
xterm -fn koi10x20

> Hopefully I can take the program and run it under wine, and see what
> filename it creates, then work out why DIR doesn't display it correctly. I
> am almost certain its because the wine cmd.exe program is converting in the
> wrong codepage somehow. I want to do an exercise of unicoding wine's cmd
> once I finish work on the commands I have left to do (mostly copy, for and
> attrib)

> I suspect your winegcc issues are use of the L"unicode string" from my
> example at a guess, but to be honest I don't know
I've already figured out it: I should pass option "-mno-cygwin" to winegcc. It 
makes winegcc link against msvcrt.dll instead of glibc.

Thanks a lot for working upon this bug!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: for_jason.tar.bz2
Type: application/x-tbz
Size: 86576 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20070418/0e313f9e/for_jason.tar-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmd_patch.diff
Type: text/x-diff
Size: 1611 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20070418/0e313f9e/cmd_patch-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: after_cmd_patch.jpg
Type: image/jpeg
Size: 104158 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20070418/0e313f9e/after_cmd_patch-0001.jpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: before_cmd_patch.jpg
Type: image/jpeg
Size: 96375 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-devel/attachments/20070418/0e313f9e/before_cmd_patch-0001.jpg

More information about the wine-devel mailing list