Project

wcswidth

0.0
No commit activity in last 3 years
No release in over 3 years
Determine terminal display width (columns) of Ruby strings via FFI bindings to libc's wcswidth() function
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 10.5
~> 3.4

Runtime

~> 1.9
 Project Readme

wcswidth [version] [ci]

Determine terminal display width (columns) of Ruby strings via FFI bindings to libc's wcswidth() function.

See unicode/display_width for a Ruby-only unicode data based approach.

Usage

require 'wcswidth/kernel_method'

# full width chars
wcswidth("!") # => 2
wcswidth("一") # => 2

# single width chars
wcswidth("A") # => 1
wcswidth("·") # => 1

# zero width chars
wcswidth("ֿ") # => 0
wcswidth("\0") # => 0

# control chars
wcswidth("\x01") # => -1
wcswidth("\n") # => -1

Without opting in for wcswidth/kernel_method it is Wcswidth.of("string")

MIT License

Copyright (C) 2016 Jan Lelis https://janlelis.com. Released under the MIT license.