FAQ
All
I'm a bit new to py coding and need to setup some code to encode/decode base
128.
Anyone here have some info they can point me to do get this done? I've been
looking around on the web for a few days and can't seem to lay my hands on
anything definitive.
Thanks in advance for your help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110214/76e46939/attachment.html>

Search Discussions

  • Ian Kelly at Feb 14, 2011 at 5:35 pm

    On Mon, Feb 14, 2011 at 10:10 AM, Verde Denim wrote:
    All
    I'm a bit new to py coding and need to setup some code to encode/decode base
    128.
    Anyone here have some info they can point me to do get this done? I've been
    looking around on the web for a few days and can't seem to lay my hands on
    anything definitive.
    Thanks in advance for your help.
    First, why do you want to do this? I ask because there is probably a
    better way to achieve what you want. I'm not aware of a standard for
    "base 128", and it does not sound to me like something that would be
    very useful.

    Base 64 is commonly used as an encoding system because it fits inside
    the 94 printable characters of ASCII and is easily implemented. It is
    also provided by the Python standard library. Why not use this
    instead?

    Cheers,
    Ian
  • Verde Denim at Feb 14, 2011 at 6:00 pm

    On Mon, Feb 14, 2011 at 12:35 PM, Ian Kelly wrote:
    On Mon, Feb 14, 2011 at 10:10 AM, Verde Denim wrote:
    All
    I'm a bit new to py coding and need to setup some code to encode/decode base
    128.
    Anyone here have some info they can point me to do get this done? I've been
    looking around on the web for a few days and can't seem to lay my hands on
    anything definitive.
    Thanks in advance for your help.
    First, why do you want to do this? I ask because there is probably a
    better way to achieve what you want. I'm not aware of a standard for
    "base 128", and it does not sound to me like something that would be
    very useful.

    Base 64 is commonly used as an encoding system because it fits inside
    the 94 printable characters of ASCII and is easily implemented. It is
    also provided by the Python standard library. Why not use this
    instead?

    Cheers,
    Ian
    Ian
    Thanks for the reply. The fact is that I don't _want_ to, but need to as a
    part of a work project. If I had a choice, base 64 would be the way to go
    since (as you point out), it's already in the standard library. If I could
    take the encoded form and translate it to base 64 and then use the standard
    library, that would work as well, but I'm not sure that there's a one-to-one
    correlation there.

    - Jack
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20110214/c6b3636b/attachment.html>
  • MRAB at Feb 14, 2011 at 5:46 pm

    On 14/02/2011 17:10, Verde Denim wrote:
    All
    I'm a bit new to py coding and need to setup some code to encode/decode
    base 128.
    Anyone here have some info they can point me to do get this done? I've
    been looking around on the web for a few days and can't seem to lay my
    hands on anything definitive.
    Thanks in advance for your help.
    http://en.wikipedia.org/wiki/LEB128
  • Verde Denim at Feb 14, 2011 at 6:03 pm

    On Mon, Feb 14, 2011 at 12:46 PM, MRAB wrote:
    On 14/02/2011 17:10, Verde Denim wrote:

    All
    I'm a bit new to py coding and need to setup some code to encode/decode
    base 128.
    Anyone here have some info they can point me to do get this done? I've
    been looking around on the web for a few days and can't seem to lay my
    hands on anything definitive.
    Thanks in advance for your help.

    http://en.wikipedia.org/wiki/LEB128
    --

    MRAB
    Thanks for the reply. The link you sent will (hopefully) give me a starting
    point. Do you know if there are particular implementations of base 128
    encoding that differ from LEB?

    - Jack
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20110214/56a0f69b/attachment.html>
  • MRAB at Feb 14, 2011 at 6:58 pm

    On 14/02/2011 18:03, Verde Denim wrote:

    On Mon, Feb 14, 2011 at 12:46 PM, MRAB <python at mrabarnett.plus.com
    wrote:

    On 14/02/2011 17:10, Verde Denim wrote:

    All
    I'm a bit new to py coding and need to setup some code to
    encode/decode
    base 128.
    Anyone here have some info they can point me to do get this
    done? I've
    been looking around on the web for a few days and can't seem to
    lay my
    hands on anything definitive.
    Thanks in advance for your help.

    http://en.wikipedia.org/wiki/LEB128
    --

    MRAB
    Thanks for the reply. The link you sent will (hopefully) give me a
    starting point. Do you know if there are particular implementations of
    base 128 encoding that differ from LEB?
    I don't know anything more about it. Implementing it should be very
    easy; it's a very simple encoding.
  • Adam Tauno Williams at Feb 14, 2011 at 7:19 pm

    On Mon, 2011-02-14 at 13:03 -0500, Verde Denim wrote:
    On Mon, Feb 14, 2011 at 12:46 PM, MRAB wrote:
    On 14/02/2011 17:10, Verde Denim wrote:
    All
    I'm a bit new to py coding and need to setup some code to
    encode/decode
    base 128.
    Anyone here have some info they can point me to do get thdone? I've
    been looking around on the web for a few days and can't seetlay my
    hands on anything definitive.
    Thanks in advance for your help.
    http://en.wikipedia.org/wiki/LEB128
    Thanks for the reply. The link you sent will (hopefully) give me a
    starting point. Do you know if there are particular implementations of
    base 128 encoding that differ from LEB?
    The ULEB128Adapter class @ <
    https://bitbucket.org/cmcqueen1975/pythondwarf/src/f2ffeabfa2a6/dwarf32.py> ???

    class ULEB128Adapter(Adapter):
    """
    Adapter for DWARF unsigned LEB128.
    """
    def _encode(self, obj, context):
    obj2 = []
    value = int(obj)
    while True:
    byte = value & 0x7F
    value >>= 7
    if value != 0:
    byte = byte | 0x80
    obj2.append(chr(byte))
    if value == 0:
    break
    return obj2
    def _decode(self, obj, context):
    value = 0
    for b in reversed(obj):
    value = value * 128 + (ord(b) & 0x7F)
    return value

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedFeb 14, '11 at 5:10p
activeFeb 14, '11 at 7:19p
posts7
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase