[win32] non-ascii/non-english file names: internal usage of file names

Andrew Bennetts andrew at canonical.com
Tue Nov 29 23:46:18 GMT 2005


On Wed, Nov 30, 2005 at 01:20:51AM +0200, Alexander Belchenko wrote:
[...]
> >Or if it is critical that the output is correct, then it will use
> >encode(txt, 'error'), which will throw an exception if a character
> >cannot be encoded properly.
> 
> But for purpose of editing commit message and show to user status of 
> tree this approach is bad: nor 'replace' nor 'error' will not desired.

If some text you want to display cannot be encoded in the console's encoding,
you have no choice.  Probably an uncommon situation, but definitely possible.

> Native python implementation of StringIO (not cStringIO) accept 
> ascii-strings or unicode-strings. So, we can use latter form.

I don't think it's wise to rely on differences between StringIO vs. cStringIO --
they're probably accidental, and likely to change in future versions of Python.

Treat files, including [c]StringIO instances, as byte-streams, and explicitly
encode unicode when writing to them.  The codecs.EncodedFile wrapper makes this
easy.

-Andrew.





More information about the bazaar mailing list