{"id":13448262,"url":"https://github.com/rspeer/python-ftfy","last_synced_at":"2025-12-12T01:04:52.702Z","repository":{"id":4405390,"uuid":"5542727","full_name":"rspeer/python-ftfy","owner":"rspeer","description":"Fixes mojibake and other glitches in Unicode text, after the fact.","archived":false,"fork":false,"pushed_at":"2024-10-30T21:00:49.000Z","size":1749,"stargazers_count":3910,"open_issues_count":10,"forks_count":123,"subscribers_count":73,"default_branch":"main","last_synced_at":"2025-05-14T08:05:04.727Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://ftfy.readthedocs.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rspeer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-08-24T16:14:59.000Z","updated_at":"2025-05-12T13:03:05.000Z","dependencies_parsed_at":"2024-04-28T01:57:25.170Z","dependency_job_id":"bb5861b5-cf42-4b18-b05b-382d916925b2","html_url":"https://github.com/rspeer/python-ftfy","commit_stats":{"total_commits":589,"total_committers":17,"mean_commits":34.64705882352941,"dds":"0.16638370118845502","last_synced_commit":"74dd0452b48286a3770013b3a02755313bd5575e"},"previous_names":["luminosoinsight/python-ftfy"],"tags_count":140,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspeer%2Fpython-ftfy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspeer%2Fpython-ftfy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspeer%2Fpython-ftfy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rspeer%2Fpython-ftfy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rspeer","download_url":"https://codeload.github.com/rspeer/python-ftfy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254101588,"owners_count":22014907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T05:01:40.378Z","updated_at":"2025-12-12T01:04:47.679Z","avatar_url":"https://github.com/rspeer.png","language":"Python","readme":"# ftfy: fixes text for you\n\n[![PyPI package](https://badge.fury.io/py/ftfy.svg)](https://badge.fury.io/py/ftfy)\n[![Docs](https://readthedocs.org/projects/ftfy/badge/?version=latest)](https://ftfy.readthedocs.org/en/latest/)\n\n```python\n\n\u003e\u003e\u003e from ftfy import fix_encoding\n\u003e\u003e\u003e print(fix_encoding(\"(à¸‡'âŒ£')à¸‡\"))\n(ง'⌣')ง\n\n```\n\nThe full documentation of ftfy is available at [ftfy.readthedocs.org](https://ftfy.readthedocs.org). The documentation covers a lot more than this README, so here are some links into it:\n\n- [Fixing problems and getting explanations](https://ftfy.readthedocs.io/en/latest/explain.html)\n- [Configuring ftfy](https://ftfy.readthedocs.io/en/latest/config.html)\n- [Encodings ftfy can handle](https://ftfy.readthedocs.io/en/latest/encodings.html)\n- [“Fixer” functions](https://ftfy.readthedocs.io/en/latest/fixes.html)\n- [Is ftfy an encoding detector?](https://ftfy.readthedocs.io/en/latest/detect.html)\n- [Heuristics for detecting mojibake](https://ftfy.readthedocs.io/en/latest/heuristic.html)\n- [Support for “bad” encodings](https://ftfy.readthedocs.io/en/latest/bad_encodings.html)\n- [Command-line usage](https://ftfy.readthedocs.io/en/latest/cli.html)\n- [Citing ftfy](https://ftfy.readthedocs.io/en/latest/cite.html)\n\n## Testimonials\n\n- “My life is livable again!”\n  — [@planarrowspace](https://twitter.com/planarrowspace)\n- “A handy piece of magic”\n  — [@simonw](https://twitter.com/simonw)\n- “Saved me a large amount of frustrating dev work”\n  — [@iancal](https://twitter.com/iancal)\n- “ftfy did the right thing right away, with no faffing about. Excellent work, solving a very tricky real-world (whole-world!) problem.”\n  — Brennan Young\n- “I have no idea when I’m gonna need this, but I’m definitely bookmarking it.”\n  — [/u/ocrow](https://reddit.com/u/ocrow)\n\n## What it does\n\nHere are some examples (found in the real world) of what ftfy can do:\n\nftfy can fix mojibake (encoding mix-ups), by detecting patterns of characters that were clearly meant to be UTF-8 but were decoded as something else:\n\n    \u003e\u003e\u003e import ftfy\n    \u003e\u003e\u003e ftfy.fix_text('âœ” No problems')\n    '✔ No problems'\n\nDoes this sound impossible? It's really not. UTF-8 is a well-designed encoding that makes it obvious when it's being misused, and a string of mojibake usually contains all the information we need to recover the original string.\n\nftfy can fix multiple layers of mojibake simultaneously:\n\n    \u003e\u003e\u003e ftfy.fix_text('The Mona Lisa doesnÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢t have eyebrows.')\n    \"The Mona Lisa doesn't have eyebrows.\"\n\nIt can fix mojibake that has had \"curly quotes\" applied on top of it, which cannot be consistently decoded until the quotes are uncurled:\n\n    \u003e\u003e\u003e ftfy.fix_text(\"l’humanitÃ©\")\n    \"l'humanité\"\n\nftfy can fix mojibake that would have included the character U+A0 (non-breaking space), but the U+A0 was turned into an ASCII space and then combined with another following space:\n\n    \u003e\u003e\u003e ftfy.fix_text('Ã\\xa0 perturber la rÃ©flexion')\n    'à perturber la réflexion'\n    \u003e\u003e\u003e ftfy.fix_text('Ã perturber la rÃ©flexion')\n    'à perturber la réflexion'\n\nftfy can also decode HTML entities that appear outside of HTML, even in cases where the entity has been incorrectly capitalized:\n\n    \u003e\u003e\u003e # by the HTML 5 standard, only 'P\u0026Eacute;REZ' is acceptable\n    \u003e\u003e\u003e ftfy.fix_text('P\u0026EACUTE;REZ')\n    'PÉREZ'\n  \nThese fixes are not applied in all cases, because ftfy has a strongly-held goal of avoiding false positives -- it should never change correctly-decoded text to something else.\n\nThe following text could be encoded in Windows-1252 and decoded in UTF-8, and it would decode as 'MARQUɅ'. However, the original text is already sensible, so it is unchanged.\n\n    \u003e\u003e\u003e ftfy.fix_text('IL Y MARQUÉ…')\n    'IL Y MARQUÉ…'\n\n## Installing\n\nftfy is a Python 3 package that can be installed using `pip` or `uv pip`:\n\n    pip install ftfy\n\n(Or use `pip3 install ftfy` on systems where Python 2 and 3 are both globally installed and `pip` refers to Python 2.)\n\nIf you use `poetry`, you can use ftfy as a dependency in the usual way (such as `poetry add ftfy`).\n\n### Local development\n\nftfy is developed using [uv](https://github.com/astral-sh/uv). You can build a virtual environment with its local dependencies by running `uv venv`, and test it with `uv run pytest`.\n\n## Who maintains ftfy?\n\nI'm Robyn Speer, also known as Elia Robyn Lake. You can find my projects\n[on GitHub](https://github.com/rspeer) and my posts on [my own blog](https://posts.arborelia.net).\n\n## Citing ftfy\n\nftfy has been used as a crucial data processing step in major NLP research.\n\nIt's important to give credit appropriately to everyone whose work you build on in research. This includes software, not just high-status contributions such as mathematical models. All I ask when you use ftfy for research is that you cite it.\n\nftfy has a citable record [on Zenodo](https://zenodo.org/record/2591652). A citation of ftfy may look like this:\n\n    Robyn Speer. (2019). ftfy (Version 5.5). Zenodo.\n    http://doi.org/10.5281/zenodo.2591652\n\nIn BibTeX format, the citation is::\n\n    @misc{speer-2019-ftfy,\n      author       = {Robyn Speer},\n      title        = {ftfy},\n      note         = {Version 5.5},\n      year         = 2019,\n      howpublished = {Zenodo},\n      doi          = {10.5281/zenodo.2591652},\n      url          = {https://doi.org/10.5281/zenodo.2591652}\n    }\n\n## Important license clarifications\n\nIf you do not follow ftfy's license, you do not have a license to ftfy.\n\nThis sounds obvious and tautological, but there are people who think open source licenses mean that they can just do what they want, especially in the field of generative AI. It's a permissive license but you still have to follow it. The [Apache license](https://www.apache.org/licenses/LICENSE-2.0) is the only thing that gives you permission to use and copy ftfy; otherwise, all rights are reserved.\n\nIf you use or distribute ftfy, you must follow the terms of the [Apache license](https://www.apache.org/licenses/LICENSE-2.0), including that you must attribute the author of ftfy (Robyn Speer) correctly.\n\nYou _may not_ make a derived work of ftfy that obscures its authorship, such as by putting its code in an AI training dataset, including the code in AI training at runtime, or using a generative AI that copies code from such a dataset.\n\nAt my discretion, I may notify you of a license violation, and give you a chance to either remedy it or delete all copies of ftfy in your possession.\n\n","funding_links":[],"categories":["Python","Data Processing","文本处理","Open-Source Software","文本数据和NLP","Vorverarbeitungstools","📦 Additional Python Libraries","Text Processing"],"sub_categories":["Data Representation","Data Cleaning and Parsing","Textnormalisierung","Miscellaneous"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspeer%2Fpython-ftfy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frspeer%2Fpython-ftfy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frspeer%2Fpython-ftfy/lists"}