package wcwidth

  1. Overview
  2. Docs
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 = 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. 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

Dependencies (2)

  1. ocaml >= "4.14"
  2. dune >= "3.3"

Dev Dependencies (2)

  1. odoc with-doc
  2. alcotest with-test

Used by

None

Conflicts

None