Python - Compress Ascii String

Posted by n0idea on Stack Overflow See other posts from Stack Overflow or by n0idea
Published on 2012-10-13T09:26:07Z Indexed on 2012/10/13 9:37 UTC
Read the original article Hit count: 194

Filed under:
|
|

I'm looking for a way to compress an ascii-based string, any help?

I need also need to decompress it. I tried zlib but with no help.

What can I do to compress the string into lesser length?

code:

def compress(request):
if request.POST:
    data = request.POST.get('input')
    if is_ascii(data):
        result = zlib.compress(data)
        return render_to_response('index.html', {'result': result, 'input':data}, context_instance = RequestContext(request))
    else:
        result = "Error, the string is not ascii-based"
        return render_to_response('index.html', {'result':result}, context_instance = RequestContext(request))
else:
    return render_to_response('index.html', {}, context_instance = RequestContext(request))

© Stack Overflow or respective owner

Related posts about python

Related posts about algorithm