Created
April 11, 2017 13:36
-
-
Save CTimmerman/aaaa1ae7917d0d6db1ae988cdbfdf949 to your computer and use it in GitHub Desktop.
Mojibake fixer
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
#!/usr/local/bin/python3 | |
# -*- encoding: utf8 -*- | |
# http://stackoverflow.com/a/39549102/819417 | |
print ( "\nEmoji to mojibake (origin):") | |
for emojiChar in ['😊','😣','👽','😎']: | |
print(emojiChar, emojiChar.encode('utf8').decode('cp1252')) | |
print ( "\nmojibake to Emoji (repair):") | |
for mojibakeString in ['😊','😣','👽','😎','🙇']: | |
print(mojibakeString, mojibakeString.encode('cp1252').decode('utf8')) | |
baka = ' ' | |
while baka: | |
baka = input('Mojibake? ') | |
print(baka, baka.encode('cp1252').decode('utf8')) |
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
$ ./mojibake.py | |
Emoji to mojibake (origin): | |
😊 😊 | |
😣 😣 | |
👽 👽 | |
😎 😎 | |
mojibake to Emoji (repair): | |
😊 😊 | |
😣 😣 | |
👽 👽 | |
😎 😎 | |
🙇 🙇 | |
Mojibake? 💋 | |
💋 💋 | |
Mojibake? 😊 | |
😊 😊 | |
Mojibake? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment