package wcwidth

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

Install

Dune Dependency

Authors

Maintainers

Sources

wcwidth-1.0.0.tbz
sha256=228cc4e9aa52c9c0fa0c07c2b4619b9cdac556a2653425b27de1f1aa611f2f12
sha512=f089b80446437d1b39983e386eb3c49aacde6a60f76e5a143a747a394225182a9e57cb6f8ccf2aa954e56f833efd7e160a707cee649fecef6323fb7ccd515d2a

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.