On 10 May 2011, at 13:00,  Richard Hipp <[email protected]> wrote:
> On Mon, May 9, 2011 at 6:21 PM, Richard Hipp <[email protected]> wrote:
> 
>> 
>> 
>> On Mon, May 9, 2011 at 5:22 PM, Konstantin Khomoutov <
>> [email protected]> wrote:
>> 
>>> The console in Cyrillic Windows does really use two completely different
>>> code pages for input and output.
>>> Supposedly they are different for any l10n of Windows, as the OP stated,
>>> just for some code pages like Latin-1 this makes no difference.
>>> 
>> 
>> Can you suggest changes to the fossil_utf8_to_mbcs() and
>> fossil_mbcs_to_utf8() functions that will get Fossil working correctly on
>> windows with Cyrillic?
>> 
> 
> Perhaps my windows i18n strategy is wrong.  Perhaps I should only convert
> from utf8 to mbcs before making system calls (fopen(), unlink(), opendir(),
> etc) and should not try to do mbcs-to-utf8 conversion for command line input
> or utf8-to-mbcs conversion for command-line output.  Instead, of converting
> input and output, simply ask the user to run "chcp 65001" prior to running
> Fossil?
> 
> Or, perhaps the command-line is just hopelessly broken on windows and we
> should simply ignore this problem all together?  Just say that Fossil works
> in all languages on unix and in English for windows?

You should let Windows do all the hard work for you at the process boundaries.

Compile the command line utility in 'unicode mode' (#define UNICODE command 
line equivalent), which gets you an API which just gives you UTF16.

To get your command line arguments in UTF16, use 

  int _tmain(int argc, TCHAR *argv[])

instead of the conventional main(), which will expand to the right thing 
depending whether UNICODE is defined.

  http://msdn.microsoft.com/en-us/library/4t912wf5(v=VS.71).aspx

Convert the arguments using WideCharToMultiByte(CP_UTF8, ...) and 
MultiByteToWideChar(CP_UTF8, ...) to get your internal UTF8 representation.

To get the output right, call SetConsoleOutputCP(CP_UTF8) and write UTF8 to 
stdout.

  http://msdn.microsoft.com/en-us/library/ms686036(VS.85).aspx

(Use above with caution -- my Windows programming memory is a little rusty.)

Ben


--
http://bens.me.uk





_______________________________________________
fossil-users mailing list
[email protected]
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to