kdialog and unicode

dumbkiwi dmbkiwi at gmail.com
Tue Apr 26 16:39:26 EDT 2005


Peter Otten <__peter__ at web.de> wrote in message news:<d4l92e$9di$05$1 at news.t-online.com>...
> Dumbkiwi wrote:
> 
> >> Just encode the data in the target encoding before passing it to
> >> os.popen():
> >> 
> >> test = os.popen('kdialog --inputbox %s' % data.encode("utf-8"))
>  
> > I had tried that, but then the text looks like crap.  The text I'm using
> > for this is Polish, and there are a lot of non-English characters in
> > there. Using this method results in some strange characters - basically it
> > looks like a file encoded in utf-8, but displayed using iso-8859-1.
> > 
> > Is this the best I can do?
> 
> I've just tried the setup you described (with German umlauts instead of
> Polish characters) on my Suse 9.1, and it works as expected with both
> Python 2.3 and 2.4. Perhaps the target encoding you need is not UTF-8. I
> would try other popular encodings used for Polish text (no idea what these
> are). sys.stdout.encoding might give you a clue.
> 
> Peter

Both sys.stdout.encoding and sys.stdin.encoding give:

ANSI_X3.4-1968

which is ascii (I think).

I'd be interested to see what your default encoding is, and why your
output was different.

Anyway, from your post, I've done some more digging, and found the
command:

sys.setappdefaultencoding()

which I've used, and it's fixed the problem (I think).

Thanks for your help.

Matt



More information about the Python-list mailing list