Created
October 31, 2018 12:59
-
-
Save east825/7a7e86fc5dda749c2680c7e5cb6f8212 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
from typing import Text, Union | |
def to_text(s: Union[bytes, Text]) -> Text: | |
if isinstance(s, bytes): | |
return s.decode(encoding=os.getenv('ENCODING', sys.stdin.encoding)) | |
return s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment