On Creating Codecs

Your Name pjoshi at bandbprintshop.net
Wed Aug 20 16:33:59 CEST 2003

I have been trying to generate codecs for my language in Python using 
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 
Now I try to use the codec from the shell and below is my session on 

>>> string = 'cde'
>>> string.encode('nepali')
Traceback (most recent call last):
  File "<pyshell#1>", line 1, in ?
  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.


More information about the Python-list mailing list