A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/janlelis/wcswidth-ruby below:

janlelis/wcswidth-ruby: FFI bindings to libc's wcswidth() to determine the actual display width of strings

Skip to content Navigation Menu Search code, repositories, users, issues, pull requests...

Saved searches Use saved searches to filter your results more quickly

Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert janlelis/wcswidth-ruby

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.

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")

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

About

FFI bindings to libc's wcswidth() to determine the actual display width of strings

Topics Resources License Code of conduct Stars Watchers Forks

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4