Registry / serialization / fold-to-ascii

fold-to-ascii

JSON →
library1.0.2.post1pypypi✓ verified 87d ago

A Python port of the Apache Lucene ASCII Folding Filter, this library converts alphabetic, numeric, and symbolic Unicode characters outside the Basic Latin block into their ASCII equivalents if they exist. It's currently at version 1.0.2.post1 and is a stable, low-cadence utility library focused on character folding rather than full transliteration.

pip install fold-to-ascii
INSTALL
IMPORT
SIG · FOLD-TO-ASCII
F
fold-to-ascii
serializationpythonv1.0.2.post1
Install
1.6s avg
Import
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.2.post1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.2MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fold
from fold_to_ascii import fold

Demonstrates the core functionality of `fold` for characters with and without direct ASCII equivalents, showing how non-folding characters are replaced with question marks.

from fold_to_ascii import fold # Example 1: Characters with direct ASCII equivalents text_with_accents = "Crème brûlée is delicious!" ascii_text = fold(text_with_accents) print(f"Original: {text_with_accents}") print(f"Folded: {ascii_text}") # Example 2: Characters without direct ASCII equivalents text_with_non_folding = "Hello, 你好 👋 world!" ascii_text_non_folding = fold(text_with_non_folding) print(f"Original: {text_with_non_folding}") print(f"Folded: {ascii_text_non_folding}")
Debug
Known issues
gotchaCharacters without a direct ASCII equivalent (e.g., CJK characters, emojis, or many symbols) are converted to '?' (question mark) characters by default, as the Lucene folding filter does not define mappings for them.
fix
Be aware of this substitution behavior. If preserving or explicitly handling non-folding characters is required, pre-process the string (e.g., remove them) or use a different library for broader transliteration needs.
affects: all
gotchaThis library performs ASCII 'folding', which is a specific type of character mapping. It is not a general-purpose 'transliteration' library that attempts to convert characters into phonetic or semantic equivalents across different languages. It strictly follows the rules of the Apache Lucene ASCII Folding Filter.
fix
Understand the distinction between ASCII folding and transliteration. For more comprehensive transliteration (e.g., '你好' to 'Ni Hao'), consider libraries like `unidecode` which offer broader character set mappings.
affects: all
Errors
Common errors & fixes
NameError: name 'fold' is not defined
The `fold` function was not imported into the current scope.
fix
Add `from fold_to_ascii import fold` at the top of your script or module.
TypeError: fold() takes exactly one argument (0 given)
The `fold` function was called without passing any string argument.
fix
Ensure you pass a string to the function, e.g., `fold('your text here')`.
AttributeError: 'module' object has no attribute 'fold'
You likely imported the module as `import fold_to_ascii` and then tried to call `fold()` directly, or did `from fold_to_ascii import *` and `fold` wasn't included (unlikely for such a small library).
fix
Use `from fold_to_ascii import fold` and then call `fold('text')`, or if you prefer `import fold_to_ascii`, call it as `fold_to_ascii.fold('text')`.
Upgrade
Version history
1.0.2.post1latest on PyPI · released May 3, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
fold-to-ascii — pip install fold-to-ascii · libregistry