Patiencer / pyscripter

Automatically exported from code.google.com/p/pyscripter
0 stars 0 forks source link

unicode problem #357

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Code:
# -*- coding: cp936 -*-

s= "中国:"
a=raw_input(s)
print a, type(a)
========================

1:
run in pyscripter: UnicodeDecodeError, s must = u"中国:", a is 
<type 'unicode'>

in idle: code run ok, if s= u"中国:", UnicodeDecodeError. a is <type 'str'>

2:
if filename like "中国.py", pyscripter could not run it, 
UnicodeDecodeError.

os: winxp sp3 chinese version, python 2.5 2.6 2.7

Original issue reported on code.google.com by pqwe...@gmail.com on 4 Mar 2010 at 8:42

GoogleCodeExporter commented 9 years ago
Your example works in PyScripter if:
 - you change s= "中国:" to s= u"中国:"
 - this is a saved file and not an unsaved buffer

For unsaved buffers use
# -*- coding: utf8 -*-
s= u"中国:"
a=raw_input(s)
print a, type(a)

and select Edit, File Encoding, UTF8 from the menu before running the script.

Original comment by pyscripter on 31 Jul 2010 at 1:45