Source Encoding GBK/GB2312

S

steven

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
 
S

Steve Holden

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
 
L

limodou

2.4 support gb2312, gbk, gb18030 and cjk codec.
you can also move these things to 2.3.
 
K

Kent Johnson

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
 

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

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top