[IPython-user] Chinese char width problem in pyreadline

Jörgen Stenarson jorgen.stenarson@bostream...
Thu Nov 1 14:06:56 CDT 2007


pan skrev:
> First time I haved tried to use 'decode(consolecodepage, "replace") '. 
> But it seems python parser will convert all the source code to utf8, and 
> also returns the parsered identifier as utf8. If you use non-ascii 
> characters as identifier, the returned identifier will be converted to 
> utf8, not the encoding as your input. But the current python does not 
> support non-ascii characters as identifier, so I use 
> decode("utf8","replace") just for displaying the encoding text of error 
> trackback about the non-ascii characters identifier correctly.
> 

I don't quite understand what you are trying to say. Lets try an 
example. The attached png shows what happens when I try to print a 
string containing swedish characters for the two cases using 
consolecodepage and utf8. As you can see using utf8 results in garbage 
being printed. What do things look like for you?

Another problem occurs when using ipython and doing completions on 
filenames containing non-ascii names. The best fix would probably be to 
patch the completer to generate unicode strings of filenames. I don't 
think we can solve this in a general way with fixes in pyreadline since 
the file system may have another encoding than the console. If you have 
any ideas here I'd love to hear them.

Thanks for working on this. I hope we can find a solution that works 
well with these wide character sets. I don't use them myself but I know 
how annoying it can be to not be able to use your full alphabet.


/Jörgen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: result-at-commandline.png
Type: image/png
Size: 16215 bytes
Desc: not available
Url : http://lists.ipython.scipy.org/pipermail/ipython-user/attachments/20071101/5deedf7c/attachment.png 


More information about the IPython-user mailing list