unicode error

1 view
Skip to first unread message

sl

unread,
Nov 17, 2006, 4:24:42 AM11/17/06
to ulipad
hi try latest Ulipad on windows (official build) / linux(not svn)

# -*- coding: utf-8 -*-
#!/usr/bin/env python
print unicode("тест", "utf-8")

default Ulipad encoding = utf8

try run from Ulipad:

UnicodeError: 'ascii' codec can't decode byte 0xd1 in position 0:
ordinal not in range(128)

=\
but when i run it from system - it work
maybe promblem in pyShell?

sys.getdefaultencoding() = ascii on it;)

limodou

unread,
Nov 17, 2006, 4:29:11 AM11/17/06
to uli...@googlegroups.com
I think you are right. pyShell is not very like stdout, and sometimes
it cann't deal with unicode very well.

--
I like python!
UliPad <<The Python Editor>>: http://wiki.woodpecker.org.cn/moin/UliPad
My Blog: http://www.donews.net/limodou

limodou

unread,
Nov 17, 2006, 4:32:18 AM11/17/06
to uli...@googlegroups.com
On 11/17/06, limodou <lim...@gmail.com> wrote:
> On 11/17/06, sl <slav...@gmail.com> wrote:
> >
> > hi try latest Ulipad on windows (official build) / linux(not svn)
> >
> > # -*- coding: utf-8 -*-
> > #!/usr/bin/env python
> > print unicode("тест", "utf-8")
> >
> > default Ulipad encoding = utf8
> >
> > try run from Ulipad:
> >
> > UnicodeError: 'ascii' codec can't decode byte 0xd1 in position 0:
> > ordinal not in range(128)
> >
> > =\
> > but when i run it from system - it work
> > maybe promblem in pyShell?
> >
> > sys.getdefaultencoding() = ascii on it;)
> >
> >
> I think you are right. pyShell is not very like stdout, and sometimes
> it cann't deal with unicode very well.
>
oh, I'm sorry it's not the pyShell's bug, but UliPad. I'll check the
bug carefully.

limodou

unread,
Nov 17, 2006, 7:34:24 AM11/17/06
to uli...@googlegroups.com
On 11/17/06, limodou <lim...@gmail.com> wrote:
> On 11/17/06, limodou <lim...@gmail.com> wrote:
> > On 11/17/06, sl <slav...@gmail.com> wrote:
> > >
> > > hi try latest Ulipad on windows (official build) / linux(not svn)
> > >
> > > # -*- coding: utf-8 -*-
> > > #!/usr/bin/env python
> > > print unicode("тест", "utf-8")
> > >
> > > default Ulipad encoding = utf8
> > >
> > > try run from Ulipad:
> > >
> > > UnicodeError: 'ascii' codec can't decode byte 0xd1 in position 0:
> > > ordinal not in range(128)
> > >
> > > =\
> > > but when i run it from system - it work
> > > maybe promblem in pyShell?
> > >
> > > sys.getdefaultencoding() = ascii on it;)
> > >
> > >
> > I think you are right. pyShell is not very like stdout, and sometimes
> > it cann't deal with unicode very well.
> >
> oh, I'm sorry it's not the pyShell's bug, but UliPad. I'll check the
> bug carefully.
>
I check the code, and I found if I run it at command line like:

python a.py > a.txt

the exception will also occured. So I think it's not the buf of
ulipad, and it's because the stdout cann't redirect the unicode to
stdout.

sl

unread,
Nov 17, 2006, 7:54:04 AM11/17/06
to ulipad
hmmm yes=)
and what way for fix it? use UTF-8 as locale? but what in windows?

limodou

unread,
Nov 17, 2006, 8:05:07 AM11/17/06
to uli...@googlegroups.com
On 11/17/06, sl <slav...@gmail.com> wrote:
>
> hmmm yes=)
> and what way for fix it? use UTF-8 as locale? but what in windows?
>
>
I think if you want to fix it, you should convert output of your
program to default locale encoding. or you should run the program in
command line.

Mario Lacunza

unread,
Nov 17, 2006, 8:32:40 AM11/17/06
to uli...@googlegroups.com
El vie, 17-11-2006 a las 21:05 +0800, limodou escribió:
> On 11/17/06, sl <slav...@gmail.com> wrote:
> >
> > hmmm yes=)
> > and what way for fix it? use UTF-8 as locale? but what in windows?
> >
> >
> I think if you want to fix it, you should convert output of your
> program to default locale encoding. or you should run the program in
> command line.
>

Are you use other encoding in windows?? because utf8 is native for Linux
boxs.

Are you use the Unicode version of python and wxpython?

--
Mario Lacunza <mlac...@gmail.com>

limodou

unread,
Nov 17, 2006, 8:34:22 AM11/17/06
to uli...@googlegroups.com
yeah, I use gbk(chinese encoding) but I god the same bug.

AK

unread,
Nov 22, 2006, 8:43:48 PM11/22/06
to ulipad
try this: print 'тест'
or
print 'тест'.decode('cp1251').encode('utf8')

Reply all
Reply to author
Forward
0 new messages