473,652 Members | 3,045 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

On Creating Codecs

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_installa tion]/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_installa tion]/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\li b\encodings\nep ali.py", line 18, in encode
return codecs.charmap_ encode(input,er rors,encoding_m ap)
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
Jul 18 '05 #1
0 1395

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

Similar topics

30
2552
by: Sean R. Lynch | last post by:
I've been playing around with Zope's RestrictedPython, and I think I'm on the way to making the modifications necessary to create a capabilities-based restricted execution system. The idea is to strip out any part of RestrictedPython that's not necessary for doing capabilities and do all security using just capabilities. The basic idea behind capabilities is that you don't give any piece of code you don't trust a reference to something...
3
4729
by: Eric Brunel | last post by:
Hi all, I just found a problem in the xreadlines method/module when used with codecs.open: the codec specified in the open does not seem to be taken into account by xreadlines which also returns byte-strings instead of unicode strings. For example, if a file foo.txt contains some text encoded in latin1: >>> import codecs >>> f = codecs.open('foo.txt', 'r', 'utf-8', 'replace') >>>
3
2674
by: Ivan Van Laningham | last post by:
Hi All-- As far as I can tell, after looking only at the documentation (and not searching peps etc.), you cannot query the codecs to give you a list of registered codecs, or a list of possible codecs it could retrieve for you if you knew enough to ask for them by name. Why not? It seems to me that if I want to try to read an unknown file using an exhaustive list of possible encodings, the best place to keep the most current list is the...
3
1922
by: Paul Watson | last post by:
$ python Python 2.4.1 (#1, May 16 2005, 15:19:29) on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import codecs >>> codecs.lookup('ascii') (<built-in function ascii_encode>, <built-in function ascii_decode>, <class encodings.ascii.StreamReader at 0xb7f1302c>, <class encodings.ascii.StreamWriter at 0xb7f82fbc>) >>> codecs.lookup('mbcs')
2
1740
by: Tamir Khason | last post by:
Anyone have ideas about creating video/audio CODECs with the Framework? -- Tamir Khason You want dot.NET? Just ask: "Please, www.dotnet.us "
7
13477
by: Mike Currie | last post by:
I'm trying to write out files that have utf-8 characters 0x85 and 0x08 in them. Every configuration I try I get a UnicodeError: ascii codec can't decode byte 0x85 in position 255: oridinal not in range(128) I've tried using the codecs.open('foo.txt', 'rU', 'utf-8', errors='strict') and that doesn't work and I've also try wrapping the file in an utf8_writer using codecs.lookup('utf8') Any clues?
1
2916
by: David Hughes | last post by:
I used this function successfully with Python 2.4 to alter the encoding of a set of database records from latin-1 to utf-8, but the same program raises an exception using Python 2.5. This small example shows the problem: import codecs fo = open('test.dat', 'w') fo.write('G\xe2teaux') fo.close()
0
2041
by: yrogirg | last post by:
Actually, I need utf-8 to utf-8 encoding which would change the text to another keyboard layout (e.g. from english to russian ghbdtn -> ÐÒÉ×ÅÔ) and would not affect other symbols. I`m totally new to python and to more or less advanced programming. I couldn`t find the answer to the question anywhere. I`ve tried create simple utf to utf codec for some symbols but it doesn`t work. Here it is.
2
2099
by: George Sakkis | last post by:
I'm trying to use codecs.open() and I see two issues when I pass encoding='utf8': 1) Newlines are hardcoded to LINEFEED (ascii 10) instead of the platform-specific byte(s). import codecs f = codecs.open('tmp.txt', 'w', encoding='utf8') s = u'\u0391\u03b8\u03ae\u03bd\u03b1' print >f, s
0
8367
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8279
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8589
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2703
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.