Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > add encoding to standard encodings works different in python 2.5?

Reply
Thread Tools

add encoding to standard encodings works different in python 2.5?

 
 
henk-jan ebbers
Guest
Posts: n/a
 
      12-22-2006
Greetings,

I use an encoding that is not available in the std python-encodings, say
encoding 'flup';
under different circumstances a user might wish different version of
'flup': a strict one or a more relaxed encoding.
(yes I know, this is terrible, but this is how it is)

in python2.4, I managed this by:
made flup_strict.py and flup_relaxed.py (coping an encoding from
python std encodings; using a encoding/decoding map as in CP1252.py,
with changes in the mapping).
placed flup_strict.py and flup_relaxed.py in my 'main'-directory
(the dir from which the my-python-source starts)
at start of my python-source: add an alias for the encoding:
encodings.aliases.aliases['flup']='flup_relaxed' (if user wishes
relaxed encoding)
this works; the encoding 'flup' is recognized and used.

when testing with python 2.5, this does not work.
my questions are:
- should this work in 2.5?
- how can i get this to work in 2.5 (nice if it would work in both 2.4
and 2.5)

btw, I use ubuntu linux edgy, with both python 2.4 and 2.5 installed

thanks, Henk-Jan


 
Reply With Quote
 
 
 
 
=?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?=
Guest
Posts: n/a
 
      12-22-2006
henk-jan ebbers schrieb:
> - how can i get this to work in 2.5 (nice if it would work in both 2.4
> and 2.5)


You should implement a lookup function, and register it with
codecs.register. Then you can structure your modules any way you like.

Regards,
Martin
 
Reply With Quote
 
 
 
 
Henk-Jan Ebbers
Guest
Posts: n/a
 
      12-29-2006
OK, I am trying to register my codecs, with codecs.register
Looking at the python doc, this seems to work different in 2.4/2.5
Can somebody help me with an example of how to register a codec?
I do not understand how this works.

regards, Henk-jan

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where to locate existing standard encodings in python News123 Python 12 11-12-2008 12:06 AM
different encodings for unicode() and u''.encode(), bug? mario Python 13 01-12-2008 11:19 PM
When I turn on my PC, it works, works, works. Problem! Fogar Computer Information 1 01-17-2006 12:57 AM
Different encodings problem: What does setting Request.ContentEncoding do? Per Bolmstedt ASP .Net 0 03-03-2004 01:46 PM
After rebooting my PC works, works, works! Antivirus problem? Adriano Computer Information 1 12-15-2003 05:30 AM



Advertisments