Skip to content

Instantly share code, notes, and snippets.

@east825
Created October 31, 2018 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save east825/7a7e86fc5dda749c2680c7e5cb6f8212 to your computer and use it in GitHub Desktop.
Save east825/7a7e86fc5dda749c2680c7e5cb6f8212 to your computer and use it in GitHub Desktop.
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