mcs07 / ChemDataExtractor

Automatically extract chemical information from scientific documents
http://chemdataextractor.org
MIT License
287 stars 112 forks source link

Fix stdin/stdout encoding issues #15

Closed mcs07 closed 7 years ago

mcs07 commented 7 years ago

This fix was motivated by a UnicodeEncodeError being raised when using the command line interface with stdout being redirected to a file use >.

For all stdout, use click’s get_text_stream so we can write unicode text and it will handle passing byte stream to stdout. For all stdin, use click’s get_binary_stream, so we get a byte stream input, similar to opening a file in binary mode.