Module: Kebab::UTF8::DumbProxy
Overview
This module provides fallback UTF-8 support when nothing else is available. It does case folding for Roman alphabet-based characters commonly used by Western European languages and little else, making it useless for Russian, Bulgarian, Greek, etc. If at all possible, Unicode or ActiveSupport should be used instead because they support the full UTF-8 character range.
Constant Summary
Constants included from Proxy
Instance Method Summary collapse
- #downcase(string) ⇒ Object
-
#normalize_utf8(string) ⇒ Object
On Ruby 2.2, this uses the native Unicode normalize method.
- #upcase(string) ⇒ Object
Methods included from Proxy
Instance Method Details
#downcase(string) ⇒ Object
16 17 18 |
# File 'lib/kebab/utf8/dumb_proxy.rb', line 16 def downcase(string) string.downcase.unpack("U*").map {|char| Mappings::DOWNCASE[char] or char}.flatten.pack("U*") end |
#normalize_utf8(string) ⇒ Object
On Ruby 2.2, this uses the native Unicode normalize method. On all other Rubies, it does a very naive Unicode normalization, which should work for this library’s purposes (i.e., Roman-based codepoints, up to U+017E). Do not use reuse this as a general solution! Use a real library like Unicode or ActiveSupport instead.
34 35 36 |
# File 'lib/kebab/utf8/dumb_proxy.rb', line 34 def normalize_utf8(string) string.unicode_normalize end |