/usr/lib/ruby/vendor_ruby/kramdown/utils/unidecoder.rb is in ruby-kramdown 1.15.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | # -*- coding: utf-8 -*-
#
#--
# Copyright (C) 2009-2016 Thomas Leitner <t_leitner@gmx.at>
#
# This file is part of kramdown which is licensed under the MIT.
#++
#
# This file is based on code originally from the Stringex library and needs the data files from
# Stringex to work correctly.
module Kramdown
module Utils
# Provides the ability to tranliterate Unicode strings into plain ASCII ones.
module Unidecoder
gem 'stringex' if defined?(Gem)
path = $:.find {|dir| File.directory?(File.join(File.expand_path(dir), "stringex", "unidecoder_data"))}
if !path
def self.decode(string)
string
end
else
CODEPOINTS = Hash.new do |h, k|
h[k] = YAML.load_file(File.join(path, "stringex", "unidecoder_data", "#{k}.yml"))
end
# Transliterate string from Unicode into ASCII.
def self.decode(string)
string.gsub(/[^\x00-\x7f]/u) do |codepoint|
begin
unpacked = codepoint.unpack("U")[0]
CODEPOINTS["x%02x" % (unpacked >> 8)][unpacked & 255]
rescue
"?"
end
end
end
end
end
end
end
|