Description

Unicode library for getting East Asian Width property

Package Information

Version1.0.0 (2017-Mar-25)
Repository https://github.com/jprekz/east_asian_width
LicenseBSL-1.0
CopyrightCopyright © 2017, jprekz
Authorsjprekz
Registered byjprekz
Dependencies none

Installation

To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

Readme

eastasianwidth

Unicode library for getting East Asian Width property

import eastasianwidth;

assert(displayWidth("あいうえお") == 10);

// '☆' is Ambiguous character
assert(displayWidth('☆') == 1);
assert(displayWidth('☆', AmbiguousCharWidth.wide) == 2);
assert(displayWidth("☆D言語くん☆") == 11);
assert(displayWidth("☆D言語くん☆", AmbiguousCharWidth.wide) == 13);

assert(eastAsianWidth('A') == EastAsianWidthProperty.F); // Fullwidth
assert(eastAsianWidth('ア') == EastAsianWidthProperty.H);  // Halfwidth
assert(eastAsianWidth('ア') == EastAsianWidthProperty.W); // Wide
assert(eastAsianWidth('A') == EastAsianWidthProperty.Na); // Narrow
assert(eastAsianWidth('☆') == EastAsianWidthProperty.A); // Ambiguous
assert(eastAsianWidth('À') == EastAsianWidthProperty.N);  // Neutral

Available versions

1.0.0 ~master