473,406 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Source Encoding GBK/GB2312

When I specify an source encoding such as:

# -*- coding: GBK -*-
or
# -*- coding: GB2312 -*-

as the first line of source, I got the following error:

SyntaxError: 'unknown encoding: GBK'
Does this mean Python does not support GBK/GB2312? What do I do?

-
narke

Jul 18 '05 #1
4 6938
st****@lczmsoft.com wrote:
When I specify an source encoding such as:

# -*- coding: GBK -*-
or
# -*- coding: GB2312 -*-

as the first line of source, I got the following error:

SyntaxError: 'unknown encoding: GBK'
Does this mean Python does not support GBK/GB2312? What do I do?


Well, *your* Python might not support GTK:

sholden@dellboy ~
$ cat test90.py
# -*- coding: GBK -*-

print "Hello!"
sholden@dellboy ~
$ python test90.py
Hello!

but Python generally appears to. Do you have encodings/gbk.py in your
library?

regards
Steve

Jul 18 '05 #2
2.4 support gb2312, gbk, gb18030 and cjk codec.
you can also move these things to 2.3.
On Wed, 23 Feb 2005 22:34:02 -0600, Steve Holden <st***@holdenweb.com> wrote:
st****@lczmsoft.com wrote:
When I specify an source encoding such as:

# -*- coding: GBK -*-
or
# -*- coding: GB2312 -*-

as the first line of source, I got the following error:

SyntaxError: 'unknown encoding: GBK'
Does this mean Python does not support GBK/GB2312? What do I do?


Well, *your* Python might not support GTK:

sholden@dellboy ~
$ cat test90.py
# -*- coding: GBK -*-

print "Hello!"

sholden@dellboy ~
$ python test90.py
Hello!

but Python generally appears to. Do you have encodings/gbk.py in your
library?

regards
Steve

--
http://mail.python.org/mailman/listinfo/python-list

--
I like python!
My Blog: http://www.donews.net/limodou
New Maillist: http://groups-beta.google.com/group/python-cn
Jul 18 '05 #3
st****@lczmsoft.com wrote:
When I specify an source encoding such as:

# -*- coding: GBK -*-
or
# -*- coding: GB2312 -*-

as the first line of source, I got the following error:

SyntaxError: 'unknown encoding: GBK'
Does this mean Python does not support GBK/GB2312? What do I do?
GB2312 is supported in Python 2.4.
GB2312 support can be added to Python 2.3 with the CJKCodecs package:
http://cjkpython.i18n.org/

Kent

-
narke

Jul 18 '05 #4
Thank you All ! I am going to update ...

Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Klaus Alexander Seistrup | last post by:
Hi, After upgrading my Python interpreter to 2.3.1 I constantly get warnings like this: DeprecationWarning: Non-ASCII character '\xe6' in file mumble.py on line 2, but no encoding declared;...
2
by: Denis S. Otkidach | last post by:
I have 2 questions about compile 1. What is the reason to encode source code to utf-8? I guess "python -U" behavior is the best choice in this case. The following snippet seems to fix this,...
30
by: Hallvard B Furuseth | last post by:
Now that the '-*- coding: <charset> -*-' feature has arrived, I'd like to see an addition: # -*- str7bit:True -*- After the source file has been converted to Unicode, cause a parse error if a...
27
by: John Roth | last post by:
PEP 263 is marked finished in the PEP index, however I haven't seen the specified Phase 2 in the list of changes for 2.4 which is when I expected it. Did phase 2 get cancelled, or is it just not...
10
by: Christopher H. Laco | last post by:
Long story longer. I need to get web user input into a backend system that a) only grocks single byte encoding, b) expectes the data transer to be 1 bytes = 1 character, and c) uses the HP Roman-6...
12
by: Tamir Khason | last post by:
I have Windows Form application recieved data from clipboard and convert its encoding based on some ruls. So doing following: //from source to multiple targets System.Text.Encoding targ1 =...
4
by: Jaroslav Jakes | last post by:
Hi, please help. Sounds so simple. We receive textfiles (customer orders) as e-mail attachment. These textfiles contain a simple structure of orders, like: custno, itemno, qty, text Since...
6
by: Marco | last post by:
Hi, I have a very common problem. I try to change my encoding from defaultencoding (UTF-16) to iso-8859-15. My source: Encoding encoder = Encoding.GetEncoding("iso-8859-15");...
1
by: mehuls | last post by:
Hi, I have a xml file as follow: ---------------------------------------- <?xml version="1.0" encoding="gb2312"?> <name>ms</name> I want to fetch the value of encoding attribute in this xml...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.