Typing UTF-8 characters in IDLE

K

kazuo fujimoto

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
 
M

mudengke

thanks, it is useful.

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

it should be work



kazuo said:
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
 
K

kazuo fujimoto

----
# 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.

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 said:
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

---------------------------------------------------
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
----------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top