module Kramdown::Utils::Unidecoder
Provides the ability to tranliterate Unicode strings into plain ASCII ones.
Constants
- CODEPOINTS
Public Class Methods
decode(string)
click to toggle source
Transliterate string from Unicode into ASCII.
# File lib/kramdown/utils/unidecoder.rb, line 28 def self.decode(string) string.gsub(/[^\x00-\x7f]/u) do |codepoint| unpacked = codepoint.unpack1("U") CODEPOINTS[sprintf("x%02x", unpacked >> 8)][unpacked & 255] rescue StandardError "?" end end