Skip to content

download_url should make use of the encoding in the Content-Type header #2

Description

@fawkesley

At the moment we're returning a file object from response.content which loses any information we had about the file's unicode encoding:

Content-Type: text/html; charset=UTF-8

We can cunningly wrap the returned file handle using the codecs module:

from cStringIO import StringIO
>>> f = StringIO(a.encode('utf-8'))
>>> f.read()
'Marat\xc3\xb3n'
>>> f.seek(0)
>>> g = codecs.getreader('utf-8')(f)
>>> print g.read()
Maratón

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions