eastasianwidth

This module provides functions to solve 'East Asian Width' problems. This functions help to create text base UI.

Usage example

Text align right with multibyte string.

import eastasianwidth

echo "hello".stringWidth        # --> 5
echo "こんにちは".stringWidth   # --> 10
echo "ABCDE".stringWidth   # --> 10
References:

Types

EastAsianWidth = enum
  fullWidth = "F", halfWidth = "H", wide = "W", narrow = "Na", ambiguous = "A", neutral = "N"

Procs

proc eastAsianWidth(codePoint: int): EastAsianWidth {...}{.raises: [], tags: [].}
eastAsianWidth returns EastAsianWidth of code point.

Examples:

from unicode import runeAtPos

doAssert 0x00003000.eastAsianWidth == fullWidth
doAssert " ".runeAtPos(0).int.eastAsianWidth == fullWidth
proc stringWidth(s: string): int {...}{.raises: [], tags: [].}
stringWidth returns text looks width.

Examples:

doAssert "".stringWidth == 0
doAssert "abcde".stringWidth == 5
doAssert "あいうえお".stringWidth == 10