ftfy-rs 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ftfy_rs-0.1.0/.github/workflows/ci.yml +49 -0
- ftfy_rs-0.1.0/.github/workflows/wheels.yml +161 -0
- ftfy_rs-0.1.0/.gitignore +14 -0
- ftfy_rs-0.1.0/AGENTS.md +24 -0
- ftfy_rs-0.1.0/CLAUDE.md +1 -0
- ftfy_rs-0.1.0/Cargo.lock +132 -0
- ftfy_rs-0.1.0/Cargo.toml +29 -0
- ftfy_rs-0.1.0/LICENSE +175 -0
- ftfy_rs-0.1.0/PKG-INFO +167 -0
- ftfy_rs-0.1.0/README.md +139 -0
- ftfy_rs-0.1.0/benchmarks/bench.py +215 -0
- ftfy_rs-0.1.0/mise.toml +39 -0
- ftfy_rs-0.1.0/pyproject.toml +47 -0
- ftfy_rs-0.1.0/python/ftfy_rs/__init__.py +409 -0
- ftfy_rs-0.1.0/python/ftfy_rs/__main__.py +6 -0
- ftfy_rs-0.1.0/python/ftfy_rs/_core.pyi +120 -0
- ftfy_rs-0.1.0/python/ftfy_rs/bad_codecs/__init__.py +51 -0
- ftfy_rs-0.1.0/python/ftfy_rs/bad_codecs/sloppy.py +77 -0
- ftfy_rs-0.1.0/python/ftfy_rs/bad_codecs/utf8_variants.py +124 -0
- ftfy_rs-0.1.0/python/ftfy_rs/badness.py +169 -0
- ftfy_rs-0.1.0/python/ftfy_rs/chardata.py +201 -0
- ftfy_rs-0.1.0/python/ftfy_rs/cli.py +147 -0
- ftfy_rs-0.1.0/python/ftfy_rs/fixes.py +141 -0
- ftfy_rs-0.1.0/python/ftfy_rs/formatting.py +30 -0
- ftfy_rs-0.1.0/python/ftfy_rs/py.typed +0 -0
- ftfy_rs-0.1.0/scripts/attribution-guard.sh +45 -0
- ftfy_rs-0.1.0/scripts/gen_tables.py +375 -0
- ftfy_rs-0.1.0/src/badness.rs +711 -0
- ftfy_rs-0.1.0/src/codecs.rs +418 -0
- ftfy_rs-0.1.0/src/fixer.rs +670 -0
- ftfy_rs-0.1.0/src/fixes.rs +799 -0
- ftfy_rs-0.1.0/src/formatting.rs +115 -0
- ftfy_rs-0.1.0/src/lib.rs +870 -0
- ftfy_rs-0.1.0/src/normalize.rs +288 -0
- ftfy_rs-0.1.0/src/tables.rs +13660 -0
- ftfy_rs-0.1.0/tests/test_differential_parity.py +117 -0
- ftfy_rs-0.1.0/tests/test_dropin_compat.py +333 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
rust:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
17
|
+
with:
|
|
18
|
+
components: rustfmt, clippy
|
|
19
|
+
- uses: Swatinem/rust-cache@v2
|
|
20
|
+
- run: cargo fmt --check
|
|
21
|
+
- run: cargo clippy --all-targets -- -D warnings
|
|
22
|
+
- run: cargo test
|
|
23
|
+
|
|
24
|
+
python:
|
|
25
|
+
strategy:
|
|
26
|
+
fail-fast: false
|
|
27
|
+
matrix:
|
|
28
|
+
os: [ubuntu-24.04, macos-latest, windows-latest]
|
|
29
|
+
python-version: ["3.9", "3.11", "3.13"]
|
|
30
|
+
runs-on: ${{ matrix.os }}
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- uses: actions/setup-python@v5
|
|
34
|
+
with:
|
|
35
|
+
python-version: ${{ matrix.python-version }}
|
|
36
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
37
|
+
- uses: Swatinem/rust-cache@v2
|
|
38
|
+
- run: python -m pip install --upgrade pip maturin pytest
|
|
39
|
+
- run: maturin build --release --out dist
|
|
40
|
+
- run: python -m pip install --no-index --find-links dist ftfy-rs
|
|
41
|
+
- run: python -m pytest
|
|
42
|
+
|
|
43
|
+
guard:
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/checkout@v4
|
|
47
|
+
with:
|
|
48
|
+
fetch-depth: 0
|
|
49
|
+
- run: bash scripts/attribution-guard.sh files
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
name: Wheels & Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
linux:
|
|
14
|
+
runs-on: ${{ matrix.runner }}
|
|
15
|
+
strategy:
|
|
16
|
+
fail-fast: false
|
|
17
|
+
matrix:
|
|
18
|
+
include:
|
|
19
|
+
- target: x86_64
|
|
20
|
+
runner: ubuntu-24.04
|
|
21
|
+
manylinux: auto
|
|
22
|
+
- target: aarch64
|
|
23
|
+
runner: ubuntu-24.04-arm
|
|
24
|
+
manylinux: auto
|
|
25
|
+
- target: x86_64
|
|
26
|
+
runner: ubuntu-24.04
|
|
27
|
+
manylinux: musllinux_1_2
|
|
28
|
+
- target: aarch64
|
|
29
|
+
runner: ubuntu-24.04-arm
|
|
30
|
+
manylinux: musllinux_1_2
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@v4
|
|
33
|
+
- uses: actions/setup-python@v5
|
|
34
|
+
with:
|
|
35
|
+
python-version: "3.12"
|
|
36
|
+
- uses: PyO3/maturin-action@v1
|
|
37
|
+
with:
|
|
38
|
+
target: ${{ matrix.target }}
|
|
39
|
+
args: --release --out dist --find-interpreter
|
|
40
|
+
sccache: "true"
|
|
41
|
+
manylinux: ${{ matrix.manylinux }}
|
|
42
|
+
- name: Test manylinux wheel
|
|
43
|
+
if: matrix.manylinux == 'auto'
|
|
44
|
+
run: |
|
|
45
|
+
python -m pip install --upgrade pip pytest
|
|
46
|
+
python -m pip install --no-index --find-links dist ftfy-rs
|
|
47
|
+
python -m pytest
|
|
48
|
+
python -c "import ftfy_rs as ftfy; assert ftfy.fix_text('✔ No problems') == '✔ No problems'"
|
|
49
|
+
- name: Test musllinux wheel
|
|
50
|
+
if: matrix.manylinux == 'musllinux_1_2'
|
|
51
|
+
run: |
|
|
52
|
+
docker run --rm -v "${{ github.workspace }}:/work" -w /work python:3.12-alpine sh -c '
|
|
53
|
+
python -m pip install --no-cache-dir pytest &&
|
|
54
|
+
python -m pip install --no-index --find-links dist ftfy-rs &&
|
|
55
|
+
python -m pytest &&
|
|
56
|
+
python -c "import ftfy_rs as ftfy; assert ftfy.fix_text(\"✔ No problems\") == \"✔ No problems\""
|
|
57
|
+
'
|
|
58
|
+
- uses: actions/upload-artifact@v4
|
|
59
|
+
with:
|
|
60
|
+
name: wheels-linux-${{ matrix.manylinux }}-${{ matrix.target }}
|
|
61
|
+
path: dist
|
|
62
|
+
|
|
63
|
+
macos:
|
|
64
|
+
runs-on: ${{ matrix.runner }}
|
|
65
|
+
strategy:
|
|
66
|
+
fail-fast: false
|
|
67
|
+
matrix:
|
|
68
|
+
include:
|
|
69
|
+
- runner: macos-15
|
|
70
|
+
target: aarch64-apple-darwin
|
|
71
|
+
- runner: macos-15-intel
|
|
72
|
+
target: x86_64-apple-darwin
|
|
73
|
+
steps:
|
|
74
|
+
- uses: actions/checkout@v4
|
|
75
|
+
- uses: actions/setup-python@v5
|
|
76
|
+
with:
|
|
77
|
+
python-version: "3.12"
|
|
78
|
+
- uses: PyO3/maturin-action@v1
|
|
79
|
+
with:
|
|
80
|
+
target: ${{ matrix.target }}
|
|
81
|
+
args: --release --out dist --find-interpreter
|
|
82
|
+
sccache: "true"
|
|
83
|
+
- name: Test macOS wheel
|
|
84
|
+
run: |
|
|
85
|
+
python -m pip install --upgrade pip pytest
|
|
86
|
+
python -m pip install --no-index --find-links dist ftfy-rs
|
|
87
|
+
python -m pytest
|
|
88
|
+
python -c "import ftfy_rs as ftfy; assert ftfy.fix_text('✔ No problems') == '✔ No problems'"
|
|
89
|
+
- uses: actions/upload-artifact@v4
|
|
90
|
+
with:
|
|
91
|
+
name: wheels-macos-${{ matrix.target }}
|
|
92
|
+
path: dist
|
|
93
|
+
|
|
94
|
+
windows:
|
|
95
|
+
runs-on: windows-latest
|
|
96
|
+
strategy:
|
|
97
|
+
fail-fast: false
|
|
98
|
+
matrix:
|
|
99
|
+
target: [x64]
|
|
100
|
+
steps:
|
|
101
|
+
- uses: actions/checkout@v4
|
|
102
|
+
- uses: actions/setup-python@v5
|
|
103
|
+
with:
|
|
104
|
+
python-version: "3.12"
|
|
105
|
+
- uses: PyO3/maturin-action@v1
|
|
106
|
+
with:
|
|
107
|
+
target: ${{ matrix.target }}
|
|
108
|
+
args: --release --out dist --find-interpreter
|
|
109
|
+
sccache: "true"
|
|
110
|
+
- name: Test Windows wheel
|
|
111
|
+
shell: bash
|
|
112
|
+
run: |
|
|
113
|
+
python -m pip install --upgrade pip pytest
|
|
114
|
+
python -m pip install --no-index --find-links dist ftfy-rs
|
|
115
|
+
python -m pytest
|
|
116
|
+
python -c "import ftfy_rs as ftfy; assert ftfy.fix_text('✔ No problems') == '✔ No problems'"
|
|
117
|
+
- uses: actions/upload-artifact@v4
|
|
118
|
+
with:
|
|
119
|
+
name: wheels-windows-${{ matrix.target }}
|
|
120
|
+
path: dist
|
|
121
|
+
|
|
122
|
+
sdist:
|
|
123
|
+
runs-on: ubuntu-24.04
|
|
124
|
+
steps:
|
|
125
|
+
- uses: actions/checkout@v4
|
|
126
|
+
- uses: actions/setup-python@v5
|
|
127
|
+
with:
|
|
128
|
+
python-version: "3.12"
|
|
129
|
+
- uses: dtolnay/rust-toolchain@stable
|
|
130
|
+
- uses: PyO3/maturin-action@v1
|
|
131
|
+
with:
|
|
132
|
+
command: sdist
|
|
133
|
+
args: --out dist
|
|
134
|
+
- name: Verify sdist metadata and source install
|
|
135
|
+
run: |
|
|
136
|
+
python -m pip install --upgrade pip twine pytest maturin
|
|
137
|
+
twine check dist/*
|
|
138
|
+
python -m pip install --no-build-isolation dist/*.tar.gz
|
|
139
|
+
python -m pytest
|
|
140
|
+
- uses: actions/upload-artifact@v4
|
|
141
|
+
with:
|
|
142
|
+
name: wheels-sdist
|
|
143
|
+
path: dist
|
|
144
|
+
|
|
145
|
+
release:
|
|
146
|
+
name: Publish to PyPI
|
|
147
|
+
runs-on: ubuntu-24.04
|
|
148
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
149
|
+
needs: [linux, macos, windows, sdist]
|
|
150
|
+
environment: pypi
|
|
151
|
+
permissions:
|
|
152
|
+
id-token: write
|
|
153
|
+
steps:
|
|
154
|
+
- uses: actions/download-artifact@v4
|
|
155
|
+
with:
|
|
156
|
+
pattern: wheels-*
|
|
157
|
+
merge-multiple: true
|
|
158
|
+
path: dist
|
|
159
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
160
|
+
with:
|
|
161
|
+
packages-dir: dist/
|
ftfy_rs-0.1.0/.gitignore
ADDED
ftfy_rs-0.1.0/AGENTS.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# ftfy-rs
|
|
2
|
+
|
|
3
|
+
Zero-dependency, pure-Rust drop-in replacement for Python `ftfy` (v6.3.1) via PyO3 + maturin.
|
|
4
|
+
|
|
5
|
+
## Architecture
|
|
6
|
+
|
|
7
|
+
- `src/tables.rs` — compact static Rust lookup tables generated by `scripts/gen_tables.py` (9 single-byte charmaps, 2,200+ HTML5 + uppercase entities, `WIDTH_MAP`, `UTF8_CLUES`, UAX #15 Unicode normalization tables, and `wcwidth` ranges).
|
|
8
|
+
- `src/codecs.rs` — all 10 `CHARMAP_ENCODINGS` (`latin-1`, `sloppy-windows-1252/1251/1250/1253/1254/1257`, `iso-8859-2`, `macroman`, `cp437`), strict `windows-1252`, `utf-8-variants` (CESU-8 + Java modified UTF-8 `\xc0\x80`), and `guess_bytes`.
|
|
9
|
+
- `src/badness.rs` — zero-allocation 8-slot ring-buffer implementation of `MOJIBAKE_CATEGORIES` and all 37 ordered branches of `BADNESS_RE`.
|
|
10
|
+
- `src/normalize.rs` — pure-Rust UAX #15 `NFC`/`NFD`/`NFKC`/`NFKD` with zero-allocation clean-block fast paths (verified against all 1,112,064 non-surrogate Unicode codepoints).
|
|
11
|
+
- `src/fixes.rs` — pure-Rust implementations of `unescape_html`, `remove_terminal_escapes`, `uncurl_quotes`, `fix_latin_ligatures`, `fix_character_width`, `fix_line_breaks`, `fix_surrogates_wtf8`, `remove_control_chars`, `remove_bom`, `restore_byte_a0`, `replace_lossy_sequences`, `decode_inconsistent_utf8`, and `fix_c1_controls`.
|
|
12
|
+
- `src/formatting.rs` — pure-Rust `character_width`, `monospaced_width`, `display_ljust`, `display_rjust`, and `display_center` (zero `wcwidth` Python dependency).
|
|
13
|
+
- `src/fixer.rs` — single-pass segment-flagged fixing pipeline (`fix_text`, `fix_text_segment`, `fix_and_explain`, `fix_encoding`, `fix_encoding_and_explain`, and GIL-released multi-core `fix_text_batch`).
|
|
14
|
+
- `src/lib.rs` — `#![forbid(unsafe_code)]`, Rust library API, and PyO3 (`abi3-py39`) `_core` extension module.
|
|
15
|
+
- `python/ftfy_rs/` — drop-in Python package mirroring `ftfy` (`fix_text`, `fix_text_batch`, `fix_and_explain`, `fix_encoding`, `fix_encoding_and_explain`, `fix_file`, `guess_bytes`, `apply_plan`, `explain_unicode`, `TextFixerConfig`, `ExplanationStep`, `ExplainedText`, `bad_codecs`, `badness`, `chardata`, `fixes`, `formatting`, `cli`).
|
|
16
|
+
|
|
17
|
+
## Conventions
|
|
18
|
+
|
|
19
|
+
- `#![forbid(unsafe_code)]` across the crate.
|
|
20
|
+
- Zero non-PyO3 Rust dependencies and zero Python runtime dependencies.
|
|
21
|
+
- Keep Python typing 3.9-compatible (`typing.Union`, `typing.Optional`, `typing.List`, `typing.Tuple`, `typing.Dict` — no runtime PEP 604 `X | Y`).
|
|
22
|
+
- Keep pytest `ids=` short so Windows `PYTEST_CURRENT_TEST` limits never break.
|
|
23
|
+
- Run `mise run check` before committing: `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`, `cargo clippy --lib --features extension-module -- -D warnings`, `cargo test`, `maturin develop --release`, `pytest`, and `scripts/attribution-guard.sh files`.
|
|
24
|
+
- Git identity: `Brixton Pham <117471232+brixtonpham@users.noreply.github.com>`. Never add AI attribution anywhere.
|
ftfy_rs-0.1.0/CLAUDE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
See [AGENTS.md](AGENTS.md) for project architecture, commands, and conventions.
|
ftfy_rs-0.1.0/Cargo.lock
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "ftfy-rs"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
dependencies = [
|
|
9
|
+
"pyo3",
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
[[package]]
|
|
13
|
+
name = "heck"
|
|
14
|
+
version = "0.5.0"
|
|
15
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
16
|
+
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
17
|
+
|
|
18
|
+
[[package]]
|
|
19
|
+
name = "libc"
|
|
20
|
+
version = "0.2.191"
|
|
21
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
22
|
+
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
|
23
|
+
|
|
24
|
+
[[package]]
|
|
25
|
+
name = "once_cell"
|
|
26
|
+
version = "1.21.4"
|
|
27
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
28
|
+
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
|
29
|
+
|
|
30
|
+
[[package]]
|
|
31
|
+
name = "portable-atomic"
|
|
32
|
+
version = "1.15.0"
|
|
33
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
34
|
+
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
|
35
|
+
|
|
36
|
+
[[package]]
|
|
37
|
+
name = "proc-macro2"
|
|
38
|
+
version = "1.0.107"
|
|
39
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
40
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
41
|
+
dependencies = [
|
|
42
|
+
"unicode-ident",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[[package]]
|
|
46
|
+
name = "pyo3"
|
|
47
|
+
version = "0.30.1"
|
|
48
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
49
|
+
checksum = "229ca13b8a15bb0d1487b81ab975bfcd97513416499a8312011b6036e42e0de4"
|
|
50
|
+
dependencies = [
|
|
51
|
+
"libc",
|
|
52
|
+
"once_cell",
|
|
53
|
+
"portable-atomic",
|
|
54
|
+
"pyo3-build-config",
|
|
55
|
+
"pyo3-ffi",
|
|
56
|
+
"pyo3-macros",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
[[package]]
|
|
60
|
+
name = "pyo3-build-config"
|
|
61
|
+
version = "0.30.1"
|
|
62
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
63
|
+
checksum = "70130e2b6dd1ee589a8788026a429561ca5c40fa7a2fa7914c2282eddae24700"
|
|
64
|
+
dependencies = [
|
|
65
|
+
"target-lexicon",
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
[[package]]
|
|
69
|
+
name = "pyo3-ffi"
|
|
70
|
+
version = "0.30.1"
|
|
71
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
72
|
+
checksum = "5e7ff73c555c286d212d4ce7e5fbda845a973c4f61bd5f160f5f2c3c2a04d1c4"
|
|
73
|
+
dependencies = [
|
|
74
|
+
"libc",
|
|
75
|
+
"pyo3-build-config",
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
[[package]]
|
|
79
|
+
name = "pyo3-macros"
|
|
80
|
+
version = "0.30.1"
|
|
81
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
82
|
+
checksum = "c46d2e5862c7bb8207e3b639f713dda3c499933444784154c11d013c5a691b60"
|
|
83
|
+
dependencies = [
|
|
84
|
+
"proc-macro2",
|
|
85
|
+
"pyo3-macros-backend",
|
|
86
|
+
"quote",
|
|
87
|
+
"syn",
|
|
88
|
+
]
|
|
89
|
+
|
|
90
|
+
[[package]]
|
|
91
|
+
name = "pyo3-macros-backend"
|
|
92
|
+
version = "0.30.1"
|
|
93
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
94
|
+
checksum = "38b89f066f2ae72a2aef52d1537ca2fcd104440ebfadee06e97aa90738a25b9b"
|
|
95
|
+
dependencies = [
|
|
96
|
+
"heck",
|
|
97
|
+
"proc-macro2",
|
|
98
|
+
"quote",
|
|
99
|
+
"syn",
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
[[package]]
|
|
103
|
+
name = "quote"
|
|
104
|
+
version = "1.0.47"
|
|
105
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
106
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
107
|
+
dependencies = [
|
|
108
|
+
"proc-macro2",
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
[[package]]
|
|
112
|
+
name = "syn"
|
|
113
|
+
version = "3.0.10"
|
|
114
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
115
|
+
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
|
|
116
|
+
dependencies = [
|
|
117
|
+
"proc-macro2",
|
|
118
|
+
"quote",
|
|
119
|
+
"unicode-ident",
|
|
120
|
+
]
|
|
121
|
+
|
|
122
|
+
[[package]]
|
|
123
|
+
name = "target-lexicon"
|
|
124
|
+
version = "0.13.6"
|
|
125
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
126
|
+
checksum = "8c447be3a2abfa84b2d91680c56600bd6b2873866de27b36ec911be705e291da"
|
|
127
|
+
|
|
128
|
+
[[package]]
|
|
129
|
+
name = "unicode-ident"
|
|
130
|
+
version = "1.0.27"
|
|
131
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
132
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
ftfy_rs-0.1.0/Cargo.toml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "ftfy-rs"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
rust-version = "1.85"
|
|
6
|
+
description = "Zero-dependency, pure-Rust drop-in replacement for Python ftfy via PyO3"
|
|
7
|
+
license = "Apache-2.0"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
repository = "https://github.com/brixtonpham/ftfy-rs"
|
|
10
|
+
keywords = ["unicode", "mojibake", "ftfy", "encoding", "pyo3"]
|
|
11
|
+
categories = ["text-processing", "encoding"]
|
|
12
|
+
|
|
13
|
+
[lib]
|
|
14
|
+
name = "ftfy_rs"
|
|
15
|
+
crate-type = ["cdylib", "rlib"]
|
|
16
|
+
|
|
17
|
+
[dependencies]
|
|
18
|
+
pyo3 = { version = "0.30", optional = true, features = ["abi3-py39"] }
|
|
19
|
+
|
|
20
|
+
[features]
|
|
21
|
+
default = []
|
|
22
|
+
python = ["dep:pyo3"]
|
|
23
|
+
extension-module = ["python", "pyo3/extension-module"]
|
|
24
|
+
|
|
25
|
+
[profile.release]
|
|
26
|
+
lto = "fat"
|
|
27
|
+
codegen-units = 1
|
|
28
|
+
opt-level = 3
|
|
29
|
+
strip = "symbols"
|
ftfy_rs-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the Work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind) to the Work without
|
|
46
|
+
modifying them.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to the Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this License, "Contribution"
|
|
54
|
+
shall mean any communication sent to Licensor, including but not
|
|
55
|
+
limited to electronic, verbal, or written communication sent
|
|
56
|
+
(including by email) to the Licensor or its representatives, including
|
|
57
|
+
but not limited to communication on electronic mailing lists, source
|
|
58
|
+
code control systems, and issue tracking systems that are managed by
|
|
59
|
+
the Licensor or its representatives for the purpose of discussing and
|
|
60
|
+
other purposes, excluding communication that is conspicuously marked
|
|
61
|
+
or otherwise designated in writing by the copyright owner as "Not a
|
|
62
|
+
Contribution."
|
|
63
|
+
|
|
64
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
65
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
66
|
+
subsequently incorporated into the Work.
|
|
67
|
+
|
|
68
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
69
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
70
|
+
worldwide, non-exclusive, royalty-free, copyright-based license to
|
|
71
|
+
reproduce, prepare Derivative Works of, publicly display, publicly
|
|
72
|
+
perform, sublicense, and distribute the Work and such Derivative Works
|
|
73
|
+
in Source or Object form.
|
|
74
|
+
|
|
75
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
76
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
77
|
+
worldwide, non-exclusive, royalty-free, irrevocable (except as stated
|
|
78
|
+
in this section) patent license to make, have made, use, offer to sell,
|
|
79
|
+
sell, import, and otherwise transfer the Work, where such license
|
|
80
|
+
applies only to those patent claims licensable by such Contributor
|
|
81
|
+
that are necessarily infringed by their Contribution(s) alone or by
|
|
82
|
+
combination of their Contribution(s) with the Work to which such
|
|
83
|
+
Contribution(s) was submitted. If You institute patent litigation
|
|
84
|
+
against You or any other entity (including a cross-claim or counterclaim
|
|
85
|
+
in a lawsuit) alleging that the Work or a Contribution incorporated
|
|
86
|
+
within the Work constitutes direct or indirect patent infringement,
|
|
87
|
+
then any patent licenses granted to You under this License for that
|
|
88
|
+
Work shall terminate as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in Source or Object form, with or
|
|
92
|
+
without modifications, and in any medium, provided that the following
|
|
93
|
+
conditions are met:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright notices, patents, trademarks,
|
|
103
|
+
and attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Work; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "Notice" text file as part of its
|
|
108
|
+
Distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the License, and a readable copy of
|
|
110
|
+
the Notice file in at least one of the following places: within
|
|
111
|
+
a Notice text file distributed as part of the Work; within the
|
|
112
|
+
Source form or documentation; or, within a display generated by
|
|
113
|
+
the Derivative Works, if and wherever such third-party notices are
|
|
114
|
+
third-party notices. The contents of the Notice file are for
|
|
115
|
+
informational purposes only and do not modify the License. You
|
|
116
|
+
may add Your own Attribution notices within Derivative Works
|
|
117
|
+
that You distribute, alongside or as an addendum to the Notice
|
|
118
|
+
text file from the Work, provided that such additional attribution
|
|
119
|
+
notices cannot be construed as modifying the License.
|
|
120
|
+
|
|
121
|
+
You may add Your own copyright statement to Your own Modifications
|
|
122
|
+
and may provide additional or different terms and conditions for
|
|
123
|
+
use, reproduction, or distribution of Your own Modifications, or for
|
|
124
|
+
any such Derivative Works as a whole, provided that Your use,
|
|
125
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
126
|
+
the conditions stated in this License.
|
|
127
|
+
|
|
128
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
129
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
130
|
+
by You to Licensor for inclusion in the Work shall be under the terms
|
|
131
|
+
and conditions of this License, unless You explicitly state otherwise.
|
|
132
|
+
|
|
133
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
134
|
+
names, trademarks, or service names of the Licensor, except as required
|
|
135
|
+
for reasonable and factual use in describing the origin of the Work and
|
|
136
|
+
reproducing the License.
|
|
137
|
+
|
|
138
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
139
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
140
|
+
Contributor provides its Work) on an "AS IS" BASIS, WITHOUT WARRANTIES
|
|
141
|
+
OR CONDITIONS OF ANY KIND, either express or implied.
|
|
142
|
+
|
|
143
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
144
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
145
|
+
unless required by applicable law (such as deliberate and grossly
|
|
146
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
147
|
+
liable to You for damages, including any direct, indirect, special,
|
|
148
|
+
incidental, or consequential damages of any character arising as a
|
|
149
|
+
result of this License or out of the use or adaptation of the Work.
|
|
150
|
+
|
|
151
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
152
|
+
the Work or Derivative Works thereof, You may choose to accept,
|
|
153
|
+
support, or offer warranty or additional obligations and/or rights
|
|
154
|
+
consistent with this License. However, in accepting such obligations,
|
|
155
|
+
You may act only on Your own behalf and on Your own responsibility,
|
|
156
|
+
and not on behalf of any other Contributor, and only if You agree to
|
|
157
|
+
indemnify, defend, and hold each Contributor harmless for any liability
|
|
158
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
159
|
+
of your accepting any such warranty or additional liability.
|
|
160
|
+
|
|
161
|
+
END OF TERMS AND CONDITIONS
|
|
162
|
+
|
|
163
|
+
Copyright 2026 Brixton Pham
|
|
164
|
+
|
|
165
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
166
|
+
you may not use this file except in compliance with the License.
|
|
167
|
+
You may obtain a copy of the License at
|
|
168
|
+
|
|
169
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
170
|
+
|
|
171
|
+
Unless required by applicable law or agreed to in writing, software
|
|
172
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
173
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
174
|
+
See the License for the specific language governing permissions and
|
|
175
|
+
limitations under the License.
|