add encoding to standard encodings works different in python 2.5?

Discussion in 'Python' started by henk-jan ebbers, Dec 22, 2006.

  1. 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
     
    henk-jan ebbers, Dec 22, 2006
    #1
    1. Advertising

  2. Re: add encoding to standard encodings works different in python2.5?

    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
     
    =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?=, Dec 22, 2006
    #2
    1. Advertising

  3. 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
     
    Henk-Jan Ebbers, Dec 29, 2006
    #3
    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. Per Bolmstedt
    Replies:
    0
    Views:
    428
    Per Bolmstedt
    Mar 3, 2004
  2. funkyj
    Replies:
    5
    Views:
    1,132
    funkyj
    Jan 20, 2006
  3. mario
    Replies:
    13
    Views:
    495
    Martin v. Löwis
    Jan 12, 2008
  4. News123
    Replies:
    12
    Views:
    508
    Tim Chase
    Nov 12, 2008
  5. udoline
    Replies:
    2
    Views:
    149
    udoline
    Sep 24, 2003
Loading...

Share This Page