Stringex::Unidecoder

Constants

CODEPOINTS

Contains Unicode codepoints, loading as needed from YAML files

Public Class Methods

decode(string) click to toggle source

Returns string with its UTF-8 characters transliterated to ASCII ones

You’re probably better off just using the added String#to_ascii

# File lib/stringex/unidecoder.rb, line 15
def decode(string)
  string.chars.map{|char| decoded(char)}.join
end
encode(codepoint) click to toggle source

Returns character for the given Unicode codepoint

# File lib/stringex/unidecoder.rb, line 20
def encode(codepoint)
  ["0x#{codepoint}".to_i(16)].pack("U")
end
get_codepoint(character) click to toggle source

Returns Unicode codepoint for the given character

# File lib/stringex/unidecoder.rb, line 25
def get_codepoint(character)
  "%04x" % character.unpack("U")[0]
end
in_yaml_file(character) click to toggle source

Returns string indicating which file (and line) contains the transliteration value for the character

# File lib/stringex/unidecoder.rb, line 31
def in_yaml_file(character)
  unpacked = character.unpack("U")[0]
  "#{code_group(unpacked)}.yml (line #{grouped_point(unpacked) + 2})"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.