[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Encoding in our APIs

From: Branko Čibej <brane_at_xbc.nu>
Date: 2005-05-04 23:18:51 CEST

Joseph Galbraith wrote:

> Peter N. Lundblad wrote:
>
>> On Mon, 2 May 2005, Joseph Galbraith wrote:
>>
>>
>>> Peter N. Lundblad wrote:
>>> For the first pass, I'd translate everything to the console
>>> code page.
>>>
>>> If we want to get smarter, we could translate to code page if
>>> stdout is a console or a pipe, but translate to the file encoding
>>> (when known) if the output is a file.
>>>
>>> Eventually, because I don't think the pipe case is deterministic
>>> (i.e., some applications of pipes will want one thing while
>>> others will want the other) I suspect we need a command line
>>> flag.
>>>
>>
>> Isn't Brakno's suggestion to use widechar variants for console output
>> the
>> best? According to him, it will handle the translation for us.
>
>
> It won't work for pipes-- one of the tricks is that the
> wide-char out functions are console output functions...
> so to use them you have to have logic that says
>
> if ( console )
> WriteConsoleW()
> else
> WriteFile()
>
> Write file takes a void*
>
> I'm not sure what happens if you use wprintf()-- but I'm
> sure it doesn't convert to the file's encoding (since
> it doesn't know what that is.)
>
> It probably converts to the current thread code page.

We're using fputs today for console output. I'm suggesting _putws, which
converts UTF-16 strings to whatever the locale encoding is. That means
we'd have to convert from UTF-8 first, but that's losless conversion,
and we get transliteration for free on output.

-- Brane

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed May 4 23:19:35 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.