package wcwidth

  1. Overview
  2. Docs
Get terminal display width of a string

Install

Dune Dependency

Authors

Maintainers

Sources

wcwidth-1.0.1.tbz
sha256=7cd177bea7dd3b5eaf6b84e269257503d9ef7e12c4623ba6ce0dbf9e20f5e3f0
sha512=bdbf11c94c76090b8687f5a60cb1c8908a1b7430b15794eec5955fac49c58e5a0648a9f241cf183962ee0bff8780f7bcb3c0996e5f230278c94131d203ed48c5

README.md.html

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
OCaml

Innovation. Community. Security.