[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: Joseph Galbraith <galb_at_vandyke.com>
Date: 2005-05-02 20:28:46 CEST

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.

>>I would think that unix has the same problem.
>>
>>You terminal expects output in one encoding (specified by LANG
>>probably), and the file may have a different encoding.
>>
>
> On UNIX, everything is expected to be in the current locale. Ofcourse,
> this model is a little simplistic in an environment where you receive
> files from people with other locale settings. But for output, you can pipe
> through a recoding program. It is not free from problems. But console
> encodings doesn't make the Windows case easier. How many files are in the
> old DOS codepages?

None of mine :-) I don't know about others.

My experience has been that the OEM charsets are used mostly
when you want line drawing characters.

Thanks,

Joseph

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon May 2 20:31:10 2005

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