Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yongrenjie/wcwidth-ocaml
wcwidth for OCaml
https://github.com/yongrenjie/wcwidth-ocaml
Last synced: 3 days ago
JSON representation
wcwidth for OCaml
- Host: GitHub
- URL: https://github.com/yongrenjie/wcwidth-ocaml
- Owner: yongrenjie
- License: mit
- Created: 2024-01-19T15:00:19.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-05-17T13:43:38.000Z (6 months ago)
- Last Synced: 2024-05-17T14:43:02.135Z (6 months ago)
- Language: Standard ML
- Size: 53.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES
- License: LICENSE
Awesome Lists containing this project
README
# wcwidth
Implementation of the `wcwidth(3)` and `wcswidth(3)` functions for OCaml, which lets you calculate the number of columns a string occupies in a terminal.
## Usage
Add `wcwidth` to your project dependencies.
```
# Wcwidth.wcswidth "hello";;
- : int = 5
# Wcwidth.wcswidth "🦆";;
- : int = 2
```## Update the character lists
The Unicode version the library uses is documented in `wcwidth/char_list.ml`.
This file also contains lists of zero-width and wide characters, and is derived from the Python [`wcwidth` package](https://pypi.org/project/wcwidth/).
This file can be updated (e.g. to use a new Unicode version) using the Python script `setup_char_lists.py`:```
python -m venv .venv
source .venv/bin/activate
python -m pip install wcwidth
python setup_char_lists.py
```