module Asciidammit

ported from asciidammit.py different API and classname (Asciidammit vs AsciiDammit)the the existing asciidammit gem

Constants

CP1252_CHARS
CP1252_MAP

from www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT

UTF8_CHARS
VERSION

Public Class Methods

demoronize( orig_str) click to toggle source
# File lib/asciidammit.rb, line 451
def self.demoronize( orig_str)
  # hex_rep_ary = []
  # orig_str.each_byte { |b| hex_rep_ary << sprintf( "%x", b) }
  # hex_rep = hex_rep_ary.join( " ")
  string = orig_str.dup
  UTF8_CHARS.each { |regex, value|
    # puts " regex: #{regex} value: #{value} orig: #{orig_str} : #{hex_rep}"
    if string =~ regex
      # puts "subbing #{regex} for #{value}"
      string.gsub!( regex, value)
    end
  }
  string
end
utf_encode( str ) click to toggle source

from redhanded.hobix.com/inspect/closingInOnUnicodeWithJcode.html

# File lib/asciidammit.rb, line 427
def self.utf_encode( str )
  str.gsub(/U\+([0-9a-fA-F]{4,4})/u){["#$1".hex ].pack('U*')}
end