thecocce / pyscripter

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

problem displaying chinese #318

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
i'm problem displaying chinese words in python interpreter. i just simple 

#!/usr/bin/env python
#!-*- coding: utf-8 -*-
print "开心" #happy

when i run, its show me "开心". my system is xp with english. didn't 
change other locale. am i setting wrong in pyscripter? because i using 
portablepython.

Original issue reported on code.google.com by dogs1...@gmail.com on 23 Jun 2009 at 8:17

GoogleCodeExporter commented 9 years ago
I assume you are using Python 2.x

You need to use
print u"开心" #happy

From the PyScripter help file.

Encoded Python Source Files

--------------------------------------------------------------------------------

PyScripter supports the PEP 263 fully.  The editor internally uses Unicode 
strings. 
When saved, Python files can be encoded in either utf-8 or ansi encoding.

UTF-8 encoded source files

You can select this encoding from the File Formats submenu of the Edit menu.  
From
that menu you can select whether UTF-8 encoded source files include the BOM 
UTF-8
signature which is detected by the Python interpreter.  This signature is also
detected by PyScripter when a file is loaded and other Windows editors. 
Although it
is not necessary you are advised to include an encoding comment such as

# -*- coding: utf-8 -*-

as the first or second line of the python script.  The advantage of using UTF-8
encoded files is that they can run without modification in other computers with
different default encoding. When using UTF-8 encoding you should specify all 
strings
that are not plain ascii as python unicode stings by adding the prefix 'u'.

Original comment by pyscripter on 28 Jun 2009 at 8:40