Module: TTY::Unicode
- Included in:
- Table::Border, Table::Operation::Truncation, Table::Operation::Wrapped
- Defined in:
- lib/tty/support/unicode.rb
Overview
A mixin to provide unicode support.
Instance Method Summary collapse
Instance Method Details
#as_unicode ⇒ Object
23 24 25 |
# File 'lib/tty/support/unicode.rb', line 23 def as_unicode yield end |
#clean_utf8(string) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/tty/support/unicode.rb', line 12 def clean_utf8(string) require 'iconv' if defined? ::Iconv converter = Iconv.new('UTF-8//IGNORE', 'UTF-8') converter.iconv(string) end rescue Exception string end |
#utf8?(string) ⇒ Boolean
7 8 9 10 |
# File 'lib/tty/support/unicode.rb', line 7 def utf8?(string) string.unpack('U*') rescue return false true end |