No commit activity in last 3 years
No release in over 3 years
Get East Asian Width from a character.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 5.10
~> 12.3
 Project Readme

East Asian Width

Get East Asian Width from a character.

'F'(Fullwidth), 'H'(Halfwidth), 'W'(Wide), 'Na'(Narrow), 'A'(Ambiguous) or 'N'(Natural).

Original Code is 東アジアの文字幅 (East Asian Width) の判定 - 中途.


This is a Ruby port of East Asian Width.

Status: b89f04d

Install

gem install east_asian_width

Usage

require 'east_asian_width'

puts EastAsianWidth.east_asian_width('₩') # -> 'F'
puts EastAsianWidth.east_asian_width('。') # -> 'H'
puts EastAsianWidth.east_asian_width('뀀') # -> 'W'
puts EastAsianWidth.east_asian_width('a') # -> 'Na'
puts EastAsianWidth.east_asian_width('①') # -> 'A'
puts EastAsianWidth.east_asian_width('ف') # -> 'N'

puts EastAsianWidth.character_length('₩') # -> 2
puts EastAsianWidth.character_length('。') # -> 1
puts EastAsianWidth.character_length('뀀') # -> 2
puts EastAsianWidth.character_length('a') # -> 1
puts EastAsianWidth.character_length('①') # -> 2
puts EastAsianWidth.character_length('ف') # -> 1

puts EastAsianWidth.length('あいうえお') # -> 10
puts EastAsianWidth.length('abcdefg') # -> 7
puts EastAsianWidth.length('¢₩。ᅵㄅ뀀¢⟭a⊙①بف') # -> 19