Description

An early draft of a way to determine the size of the characters using EastAsianWidth.txt, based on the very early draft of a Ruby interface to UnicodeData.txt by runpaint.

Install

Install the gem with

gem install unicode-display_width

Usage

require 'unicode/display_width'

The easy way is to use the String#display_size method:

"⚀".display_width #=> 1
'一'.display_width #=> 2

To obtain more detailed data, you can use the following syntax:

Unicode::DiplayWidth.codepoint( c )

Bugs / TODO

Since it is not tested extensively, it does probably not work correctly for all characters… For example, there is a class of unicode characters, which is not exactly defined to be narrow or full-width (“ambiguous”). This gem currently gives them a size of 1, which is not always correct.

Furthermore, the index data structure can be improved.

Copyright © 2011 Jan Lelis, rbjl.net, released under the MIT license.

Contains code by runpaint: Copyright © 2009 Run Paint Run Run

Contains EastAsianWidth.txt: Copyright © 1991-2010 Unicode, Inc.

J-_-L