module DTA::CharacterConversion

Constants

CONVERSION_MAP_UTF8

Public Instance Methods

dta_string(string) click to toggle source
# File lib/payment_dta/character_conversion.rb, line 246
def dta_string(string)
  encode_characters(map_characters(string))
end
encode_characters(string) click to toggle source
# File lib/payment_dta/character_conversion.rb, line 242
def encode_characters(string)
  string.encode('iso-8859-1')
end
map_characters(string) click to toggle source
# File lib/payment_dta/character_conversion.rb, line 229
def map_characters(string)
  new_string = ""
  string.each_char do |character|
    code = character.bytes.to_a.join('').to_i
    if CONVERSION_MAP_UTF8.has_key?(code)
      new_string << CONVERSION_MAP_UTF8[code][:convert_to]
    else
      new_string << ' '
    end
  end
  new_string
end