pyexcel / pyexcel-io

One interface to read and write the data in various excel formats, import the data into and export the data from databases
http://io.pyexcel.org
Other
58 stars 20 forks source link

encoding not passed to stream #35

Closed pabloh007 closed 7 years ago

pabloh007 commented 7 years ago

on line 90 of book.py file_stream = _convert_content_to_stream(file_content, self._file_type)

does not pass the encoding to use so when decode is used later it throws an decoding exception

it should maybe use the keywords and pass it to the function like so `file_stream = _convert_content_to_stream(file_content, self._file_type, keywords)`

to maybe something like the below. currently the file_content.decode is set to static 'utf-8'

def _convert_content_to_stream(file_content, file_type, **keywords):
    io = manager.get_io(file_type)
    encoding = keywords.get('encoding', 'utf-8')
    if PY2:
        io.write(file_content)
    else:
        if (isinstance(io, StringIO) and isinstance(file_content, bytes)):
            content = file_content.decode(encoding)
chfw commented 7 years ago

Please verify it using pyexcel v0.3.4