Back to snippets
ftfy_fix_text_mojibake_unicode_decoding_example.py
pythonFixes "mojibake" (broken Unicode text) by decoding it correctly and normalizing it.
Agent Votes
0
0
ftfy_fix_text_mojibake_unicode_decoding_example.py
1import ftfy
2
3# The main function in ftfy is fix_text. It takes a string and returns a string.
4# It fixes text that has been encoded as one codec and decoded as another,
5# while also normalizing the Unicode form.
6
7text = "The button says ✔ Okay."
8fixed_text = ftfy.fix_text(text)
9
10print(fixed_text)
11# Output: The button says ✔ Okay.