|
1 | 1 | # UnicodeFix
|
2 | 2 |
|
3 |
| -Normalizes Unicode to ASCII equivalents |
| 3 | +Normalizes Unicode to ASCII equivalents. |
| 4 | + |
| 5 | +**I'm getting this out quickly as people need it. Updates will follow to polish this up more soon.** |
| 6 | + |
| 7 | +- [UnicodeFix](#unicodefix) |
| 8 | + - [Installation](#installation) |
| 9 | + - [Usage](#usage) |
| 10 | + - [Shortcut for macOS](#shortcut-for-macos) |
| 11 | + - [To add the shortcut:](#to-add-the-shortcut) |
| 12 | + - [What's in This Repo:](#whats-in-this-repo) |
| 13 | + - [Contributing](#contributing) |
| 14 | + - [Support This and Other Projects I Have](#support-this-and-other-projects-i-have) |
| 15 | + - [License](#license) |
4 | 16 |
|
5 | 17 | ## Installation
|
6 | 18 |
|
7 |
| -Clone the repository somewhere on your system. You will need to pop up a terminal window to do this. |
| 19 | +Clone the repository somewhere on your system. You will need to pop open a terminal window to do this. |
8 | 20 |
|
9 |
| -Then copy and paste the following commands into the command window. |
| 21 | +Then copy and paste the following commands into the terminal: |
10 | 22 |
|
11 | 23 | ```bash
|
12 | 24 | git clone https://github.com/unixwzrd/UnicodeFix.git
|
13 | 25 | cd UnicodeFix
|
14 | 26 | bash setup.sh
|
15 | 27 | ```
|
16 | 28 |
|
17 |
| -Setup will create a virtual environment to keep your system python clean. |
18 |
| -It will add the items needed to startup the script into your .bashrc |
| 29 | +Setup will create a virtual environment to keep your system Python clean. |
| 30 | +It will also add the items needed to start the script into your `.bashrc`. |
19 | 31 |
|
20 |
| -Look at the [setup.sh](setup.sh) file to see what it does if you like, it's very simple. |
| 32 | +Look at the [setup.sh](setup.sh) file to see exactly what it does if you like — it's very simple. |
21 | 33 |
|
22 |
| -The .bashrc items are necessary because I will have a shortcut you may use from the macOS context menu to run the script shortly. |
| 34 | +The `.bashrc` items are necessary because I have a Shortcut you may use from the macOS context menu to run the script directly. |
23 | 35 |
|
24 | 36 | ## Usage
|
25 | 37 |
|
26 | 38 | ```bash
|
27 | 39 | (python-3.10-PA-dev) [unixwzrd@xanax: UnicodeFix]$ python bin/cleanup-text.py --help
|
28 |
| -usage: cleanup-text.py [-h] [-o OUTPUT] [infile] |
| 40 | +usage: cleanup-text.py [-h] [infile ...] |
29 | 41 |
|
30 | 42 | Clean Unicode quirks from text.
|
31 | 43 |
|
32 | 44 | positional arguments:
|
33 |
| - infile Input file (or use STDIN) |
| 45 | + infile Input file(s) |
34 | 46 |
|
35 | 47 | options:
|
36 |
| - -h, --help show this help message and exit |
37 |
| - -o OUTPUT, --output OUTPUT |
38 |
| - Output file (default: STDOUT) |
| 48 | + -h, --help Show this help message and exit |
39 | 49 |
|
| 50 | +Example: |
40 | 51 | python bin/cleanup-text.py <input_file>
|
41 | 52 | ```
|
42 | 53 |
|
43 |
| -## What's in this repo: |
| 54 | +The output file will be named the same as the input file, but with a `.clean.txt` extension. |
| 55 | + |
| 56 | +You can select multiple files at once. |
| 57 | + |
| 58 | +## Shortcut for macOS |
| 59 | + |
| 60 | +There is a "Shortcut" file in the `macOS/` directory which may be imported into the Shortcuts app. |
| 61 | +It will allow the script to be run as a **Quick Action** from the Finder "Right Click" menu. |
| 62 | +This allows selecting multiple files and scrubbing the Unicode quirks from them in bulk. |
| 63 | + |
| 64 | +### To add the shortcut: |
| 65 | + |
| 66 | +1. Open the "Shortcuts" app. |
| 67 | + |
| 68 | +  |
| 69 | + |
| 70 | +2. Go to `File -> Import...` |
| 71 | + |
| 72 | +  |
| 73 | + |
| 74 | +3. Navigate to the `macOS` directory in this repository and select the `Strip Unicode.shortcut` file. |
| 75 | + |
| 76 | +  |
| 77 | + |
| 78 | +4. You will need to open the shortcut and change the location path of the `cleanup-text.py` script. |
| 79 | + |
| 80 | +  |
| 81 | + |
| 82 | +5. You may have to restart Finder (use `Command+Option+Esc`, select Finder, and click "Relaunch"). |
| 83 | + |
| 84 | +6. Once setup, right-click on a file or multiple files in Finder, go to `Quick Actions`, and select `Strip Unicode`. |
| 85 | + |
| 86 | + This will invoke the script on the selected files and create `.clean.txt` versions. |
| 87 | + |
| 88 | +Strip all the Unicode quirks out of your text files right in the finder using a Quick Action! |
| 89 | + |
| 90 | +If you know a better way for Linux or Windows users, feel free to submit a PR with your improvements. |
| 91 | + |
| 92 | +## What's in This Repo: |
| 93 | + |
| 94 | +- [bin/cleanup-text.py](bin/cleanup-text.py) — The script that cleans up the text. |
| 95 | +- [bin/cleanup-text](bin/cleanup-text) — A symlink without the `.py` extension for prettier usage in scripts. |
| 96 | +- [setup.sh](setup.sh) — A script that sets up the virtual environment. |
| 97 | +- [LICENSE](LICENSE) — The license for the project. |
| 98 | +- [README.md](README.md) — This file. |
| 99 | +- [requirements.txt](requirements.txt) — The dependencies needed to run. |
| 100 | +- [data/](data/) — Sample files full of Unicode issues for testing. |
| 101 | +- [docs/](docs/) — Supporting documentation for the project. |
| 102 | +- [macOS/](macOS/) — The Shortcut file for macOS users. |
| 103 | + |
| 104 | +## Contributing |
| 105 | + |
| 106 | +If you have suggestions, enhancements, or fixes, feel free to open an issue or pull request! |
| 107 | +Testing and feedback are also very welcome. |
| 108 | + |
| 109 | +## Support This and Other Projects I Have |
| 110 | + |
| 111 | +AI and Unix are my passions — but I need to pay the bills too. |
| 112 | + |
| 113 | +If you find this project useful, please tell others, and consider supporting my work: |
| 114 | + |
| 115 | +- [Patreon](https://www.patreon.com/unixwzrd) |
| 116 | +- [Buy me a Ko-Fi](https://ko-fi.com/unixwzrd) |
| 117 | +- [Buy me a Coffee](https://www.buymeacoffee.com/unixwzrd) |
44 | 118 |
|
45 |
| -- [bin/cleanup-text.py](bin/cleanup-text.py) - The script that cleans up the text. |
46 |
| -- [setup.sh](setup.sh) - A script that sets up the environment to run the script. |
47 |
| -- [LICENSE](LICENSE) - The license for the project. |
48 |
| -- [README.md](README.md) - This file. |
49 |
| -- [requirements.txt](requirements.txt) - The dependencies for the project. |
50 |
| -- [data/](data/) - A directory with sample files full of unicode to test with. |
| 119 | +Thank you! |
51 | 120 |
|
52 |
| -## Coming SOon |
53 |
| -- macSO Shortcut |
| 121 | +## License |
54 | 122 |
|
55 |
| -## License |
56 |
| - |
| 123 | +Copyright 2025 |
| 124 | + |
57 | 125 |
|
58 | 126 | [MIT License](LICENSE)
|
59 | 127 |
|
|
0 commit comments