On Creating Codecs

Discussion in 'Python' started by Your Name, Aug 20, 2003.

  1. Your Name

    Your Name Guest

    Hi,
    I have been trying to generate codecs for my language in Python using
    gencodec.py.
    The problem is the codec created does not work.
    Here is the process that I followed.
    I created a directory inside [python_installation]/tools/scripts and
    put in a text file containing the mapping.
    Here is a sample from it.
    0x63 0x0915 # acsii letter c
    0x64 0x0916
    0x65 0x0917 # ascii letter e
    0x66 0x0918
    0x67 0x0919
    As my Language was not standardized before Unicode, I have to use
    fonts that have been developed using the ascii character set.
    Now in the table I map ascii representative values to the char
    encoding in Unicode.
    Now using gencodec.py I generate the codecs. It gives me a py script
    file, which I placed in the [python_installation]/lib/encodings
    directory.
    Now I try to use the codec from the shell and below is my session on
    it.

    >>> string = 'cde'
    >>> string.encode('nepali')

    Traceback (most recent call last):
    File "<pyshell#1>", line 1, in ?
    string.encode('nepali')
    File "C:\Python22\lib\encodings\nepali.py", line 18, in encode
    return codecs.charmap_encode(input,errors,encoding_map)
    UnicodeError: charmap encoding error: character maps to <undefined>
    >>>


    I may be doing something wrong. Can you please tell me how to go about
    it. I am using Python 2.2 on Windows XP.
    Thank you.

    PRJoshi
    Your Name, Aug 20, 2003
    #1
    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. Jason Teagle
    Replies:
    8
    Views:
    7,075
    Jon A. Cruz
    Feb 8, 2004
  2. Radovan Garabik

    how to register private python codecs?

    Radovan Garabik, Jul 1, 2003, in forum: Python
    Replies:
    1
    Views:
    722
    Steven Taschuk
    Jul 1, 2003
  3. derek / nul

    Newbie problem with codecs

    derek / nul, Aug 21, 2003, in forum: Python
    Replies:
    10
    Views:
    736
    derek / nul
    Aug 23, 2003
  4. Marko Faldix
    Replies:
    8
    Views:
    400
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Dec 15, 2003
  5. Karl Knechtel
    Replies:
    2
    Views:
    357
    Walter Dörwald
    Jul 10, 2012
Loading...

Share This Page