Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
This gem adds String#display_size to get the display size of a string using EastAsianWidth.txt.
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
data fix regex for new east asian width format + don't autobuild index if …
lib/unicode
spec
.editorconfig
.gemspec add rake to gemfile and remove Gemfile.lock from repo
.gitignore add rake to gemfile and remove Gemfile.lock from repo
.rspec specs
.travis.yml specs
CHANGELOG.txt don't include EastAsianWidth.txt in gem (only index)
Gemfile specs
LICENSE.txt release 0.2.0
README.rdoc
Rakefile fix Rakefile

README.rdoc

unicode/display_width

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 character data, you can use the following syntax:

Unicode::DisplayWidth.codepoint( c )

Ambigous Characters

The display_width method takes an optional argument, which will be used as width for characters defined as “ambigious”. The default value is 1.

Copyright

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

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

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

J-_-L

Something went wrong with that request. Please try again.