package wcwidth
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page
Get terminal display width of a string
Install
dune-project
Dependency
Authors
Maintainers
Sources
v1.1.0.tar.gz
md5=1efe8d35df972a05b9c041c2918c7c60
sha512=f3ebb5977894d2659bf6c13c8d6b744bdab79d425dde1b85aeac999776d3e705f3a2f9e36f6f3c2c12190a4b4466059029dd22edaab3c3f38bc2853bc038a8e3
Description
Get terminal display width of a string
Published: 23 Mar 2026
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 = 2Update 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. 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
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page