Timeline for answer to Python decode from a specific string by anthony sottile
Current License: CC BY-SA 4.0
Post Revisions
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 10, 2020 at 18:03 | comment | added | NealWalters | @Sottile - Thanks! I guess I just have one day of sadness compared to your years and years. | |
| Nov 10, 2020 at 17:46 | comment | added | anthony sottile |
your second one is probably cp1252 mojibake: >>> s.encode('cp1252').decode('utf-8') 'Gədəbəy'
|
|
| Nov 10, 2020 at 17:29 | comment | added | NealWalters | @lenz - cool, I used that library. I had some that caused an error on the decode solution, but ftfy didn't decode them either. I put a "Part 2" in my question above for a weird one that wouldn't fix. | |
| Nov 10, 2020 at 8:24 | comment | added | lenz |
@NealWalters a bunch of people collected their experience from more years of sadness and cast them into the Python library ftfy (fixes text for you), which can go directly from garbled text: ftfy.fix_text("Al Baţḩah") → 'Al Baţḩah'. It's not error-free (because this task is basically a guessing problem), but it's pretty good.
|
|
| Nov 10, 2020 at 4:08 | history | edited | anthony sottile | CC BY-SA 4.0 |
added 2 characters in body
|
| Nov 10, 2020 at 4:07 | comment | added | anthony sottile | years and years of sadness | |
| Nov 10, 2020 at 4:04 | history | edited | NealWalters | CC BY-SA 4.0 |
added source code instead of command line format
|
| Nov 10, 2020 at 3:59 | comment | added | NealWalters | You're a genius! How did you arrive at that conclusion? | |
| Nov 10, 2020 at 3:58 | vote | accept | NealWalters | ||
| Nov 10, 2020 at 2:22 | history | answered | anthony sottile | CC BY-SA 4.0 |