Typing UTF-8 characters in IDLE

kazuo fujimoto fujimoto at sakushin-u.ac.jp
Wed Oct 11 21:25:24 EDT 2006


----
# I replied to this message by 'Reply' function of my mailer. So this
message was not sent to python - list, so I put it again to the
python-list.
#
-----
Thank you for your reply.

On 30 Sep 2006 12:34:59 -0700
"mudengke at gmail.com" <mudengke at gmail.com> wrote:

> thanks, it is useful.
> 
> but ,why this line "encoding = locale.getdefaultlocale()[1]" in
> original file"IOBinding.py " ,
> don't work?

If my windows set "endoding" to utf-8 here, it  will work for my
puropose.

But windows only can set encoding to default setting of my Local, for me
it is cp932, Japanese. So if I input Hnagul here, 

"Unsupported Characters in input" error will arise.

So I am expecting that Idle will have a settings in its configration to
encoding to UTF-8 , inspite of locale.getdefaultlocale()[1].

Ofcourse it is not good for winodws95/98 users, but very useful for
Windows XP users.

> it should be work

reagrds.

kazuo

> kazuo fujimoto wrote:
> > Ricky,
> >
> > I found your message now, because I also would encounter the same
> > problem.
> >
> >
> > > A few unicode tutorials on the web show that it's possible to type
> > > unicode characters into the IDLE gui...
> > >
> > > However, when i type korean (hangul) characters it complains:
> > >
> > > Unsupported Characters in input
> > >
> > > I don't have a great understanding of unicode, but when I use a UTF-8
> > > source file with korean strings in, and run it as a CGI script it
> > > works fine.
> > >
> > > I'm using python 2.3.3 on win XP.
> > >
> > > Any tutorials / info anyone could point me to? Thanks...
> >
> > Now I am using Hangle with Japaese.
> >
> > What I did is as follow.
> >
> > My Python is now 2.4.3
> >
> > 1) open the IOBinding.py in $python/idellib
> > 2) see the block just after line35, and insert one line.
> > ----
> > encoding = "ascii"                                       # line 35
> > if sys.platform == 'win32':
> >     # On Windows, we could use "mbcs". However, to give the user
> >     # a portable encoding name, we need to find the code page
> >     try:
> >         encoding = locale.getdefaultlocale()[1]
> >         codecs.lookup(encoding)
> >     except LookupError:
> >         pass
> >     encoding = 'utf-8' ## <- this line force the encoding to utf-8.
> > -----
> > 3) save the file and quit Idle and reopen Idle.
> >
> > I hope my experience will solve your problem.
> >
> > (It has passed 2 years and more, so you might already solve the problem.
> > I you know better solution, please inform me.)
> > 
> > kazuo
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list

--------------------------------------------------- 
kazuo fujimoto <fujimoto at sakushin-u.ac.jp>
Sakushin Gakuin University, Faculty Human & Culture
http://www.sakushin-u.ac.jp/~fujimoto
PGP:D664 D542 D578 5B39  BB2E 50AA 6FEC 2FE7
----------------------------------------------------




More information about the Python-list mailing list