Source Encoding GBK/GB2312

Discussion in 'Python' started by steven@lczmsoft.com, Feb 24, 2005.

  1. Guest

    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
     
    , Feb 24, 2005
    #1
    1. Advertising

  2. Steve Holden Guest

    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
     
    Steve Holden, Feb 24, 2005
    #2
    1. Advertising

  3. limodou Guest

    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 <> wrote:
    > 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
     
    limodou, Feb 24, 2005
    #3
  4. Kent Johnson Guest

    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
    >
     
    Kent Johnson, Feb 24, 2005
    #4
  5. Guest

    Thank you All ! I am going to update ...
     
    , Feb 26, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steven Bethard

    elementtree and gbk encoding

    Steven Bethard, Mar 14, 2006, in forum: Python
    Replies:
    12
    Views:
    1,023
    Steven Bethard
    Mar 15, 2006
  2. moonhkt

    change ISO8859-1 to GB2312

    moonhkt, May 19, 2010, in forum: Java
    Replies:
    17
    Views:
    1,678
    RedGrittyBrick
    May 26, 2010
  3. Replies:
    7
    Views:
    407
    Anthony Jones
    Oct 12, 2006
  4. Stanley Xu
    Replies:
    2
    Views:
    638
    Stanley Xu
    Mar 23, 2011
  5. Alont
    Replies:
    0
    Views:
    130
    Alont
    Aug 27, 2004
Loading...

Share This Page