Skip to content

katzer/mruby-unicode-display_width

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unicode::DisplayWidth for mruby!
Build Status Build status

Determines the monospace display width of a string in Ruby. Implementation inspired by unicode-display_width and based on http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c from the University of Cambridge.

Installation

Add the line below to your build_config.rb:

MRuby::Build.new do |conf|
  # ... (snip) ...
  conf.gem 'mruby-unicode-display_width'
end

Or add this line to your aplication's mrbgem.rake:

MRuby::Gem::Specification.new('your-mrbgem') do |spec|
  # ... (snip) ...
  spec.add_dependency 'mruby-unicode-display_width'
end

Usage

The interace follows unicode-display_width. However custom overwrites nor the 2nd parameter for ambiguous values aren't supported.

Unicode::DisplayWidth.of("⚀") # => 1
Unicode::DisplayWidth.of("一") # => 2

With String Extension:

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

Development

Clone the repo:

$ git clone https://github.com/katzer/mruby-unicode-display_width.git && cd mruby-unicode-display_width/

Compile the source:

$ rake compile

Run the tests:

$ rake test

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/katzer/mruby-unicode-display_width.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

The gem is available as open source under the terms of the MIT License.

Made with 😋 in Leipzig

© 2017 Sebastián Katzer

About

Monospace Unicode character width in mruby

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published