safaribooks icon indicating copy to clipboard operation
safaribooks copied to clipboard

enconding issue for 9781119508199

Open danilohgds opened this issue 5 years ago • 0 comments

[#] Unhandled Exception: 'charmap' codec can't encode characters in position 85-91: character maps to (type: UnicodeEncodeError)

Swaping the enconding from utf-8 to utf-16 seemed to pass this problem, however why is UTF-8 prefered over UTF-16?

   def out(self, put):
        pattern = "\r{!s}\r{!s}\n"
        try:
            s = pattern.format(" " * self.columns, str(put, "utf-16", "replace"))

        except TypeError:
            s = pattern.format(" " * self.columns, put)

        sys.stdout.write(s)

danilohgds avatar Jan 16 '20 18:01 danilohgds