Last active
May 9, 2016 17:59
-
-
Save vbalien/f0ce99f193ce540e8f1563496fcdc8c7 to your computer and use it in GitHub Desktop.
문자 byte배열 인코딩 타입 추측
This file contains 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
def guess_encoding(text): | |
guess_list = ['euc-kr', 'utf-8', 'utf-16'] | |
for best_enc in guess_list: | |
try: | |
str(text, best_enc, "strict") | |
except UnicodeDecodeError: | |
pass | |
else: | |
break | |
return best_enc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment