tests/rfeedparser_test_helper.rb
def translate_data(data)
  if data[0..3] == "\x4c\x6f\xa7\x94"
    # EBCDIC
    data = _ebcdic_to_ascii(data)
  elsif data[0..3] == "\x00\x3c\x00\x3f"
    # UTF-16BE
    data = uconvert(data, 'utf-16be', 'utf-8')
  elsif data.size >= 4 and data[0..1] == "\xfe\xff" and data[2..3] != "\x00\x00"
    # UTF-16BE with BOM
    data = uconvert(data[2..-1], 'utf-16be', 'utf-8')
  elsif data[0..3] == "\x3c\x00\x3f\x00"
    # UTF-16LE
    data = uconvert(data, 'utf-16le', 'utf-8')
  elsif data.size >=4 and data[0..1] == "\xff\xfe" and data[2..3] != "\x00\x00"
    # UTF-16LE with BOM
    data = uconvert(data[2..-1], 'utf-16le', 'utf-8')
  elsif data[0..3] == "\x00\x00\x00\x3c"
    # UTF-32BE
    data = uconvert(data, 'utf-32be', 'utf-8')
  elsif data[0..3] == "\x3c\x00\x00\x00"
    # UTF-32LE
    data = uconvert(data, 'utf-32le', 'utf-8')
  elsif data[0..3] == "\x00\x00\xfe\xff"
    # UTF-32BE with BOM
    data = uconvert(data[4..-1], 'utf-32BE', 'utf-8')
  elsif data[0..3] == "\xff\xfe\x00\x00"
    # UTF-32LE with BOM
    data = uconvert(data[4..-1], 'utf-32LE', 'utf-8')
  elsif data[0..2] == "\xef\xbb\xbf"
    # UTF-8 with BOM
    data = data[3..-1]
  else
    # ASCII-compatible
  end
  return data
end
# Not configurable, hard coded in the xml files
Not configurable, hard coded in the xml files
Not configurable hard coded in the xml files
def translate_data(data)
  if data[0..3] == "\x4c\x6f\xa7\x94"
    data = _ebcdic_to_ascii(data)
  elsif data[0..3] == "\x00\x3c\x00\x3f"
    data = uconvert(data, 'utf-16be', 'utf-8')
  elsif data.size >= 4 and data[0..1] == "\xfe\xff" and data[2..3] != "\x00\x00"
     with BOM
    data = uconvert(data[2..-1], 'utf-16be', 'utf-8')
  elsif data[0..3] == "\x3c\x00\x3f\x00"
    data = uconvert(data, 'utf-16le', 'utf-8')
  elsif data.size >=4 and data[0..1] == "\xff\xfe" and data[2..3] != "\x00\x00"
     with BOM
    data = uconvert(data[2..-1], 'utf-16le', 'utf-8')
  elsif data[0..3] == "\x00\x00\x00\x3c"
    data = uconvert(data, 'utf-32be', 'utf-8')
  elsif data[0..3] == "\x3c\x00\x00\x00"
    data = uconvert(data, 'utf-32le', 'utf-8')
  elsif data[0..3] == "\x00\x00\xfe\xff"
     with BOM
    data = uconvert(data[4..-1], 'utf-32BE', 'utf-8')
  elsif data[0..3] == "\xff\xfe\x00\x00"
     with BOM
    data = uconvert(data[4..-1], 'utf-32LE', 'utf-8')
  elsif data[0..2] == "\xef\xbb\xbf"
    data = data[3..-1]
  else
  end
  return data
end
def translate_data ( data ) if data [ 0 .. 3 ] == "\x4c\x6f\xa7\x94" data = _ebcdic_to_ascii ( data ) elsif data [ 0 .. 3 ] == "\x00\x3c\x00\x3f" data = uconvert ( data , 'utf-16be' , 'utf-8' ) elsif data . size >= 4 and data [ 0 .. 1 ] == "\xfe\xff" and data [ 2 .. 3 ] != "\x00\x00" data = uconvert ( data [ 2 .. - 1 ] , 'utf-16be' , 'utf-8' ) elsif data [ 0 .. 3 ] == "\x3c\x00\x3f\x00" data = uconvert ( data , 'utf-16le' , 'utf-8' ) elsif data . size >= 4 and data [ 0 .. 1 ] == "\xff\xfe" and data [ 2 .. 3 ] != "\x00\x00" data = uconvert ( data [ 2 .. - 1 ] , 'utf-16le' , 'utf-8' ) elsif data [ 0 .. 3 ] == "\x00\x00\x00\x3c" data = uconvert ( data , 'utf-32be' , 'utf-8' ) elsif data [ 0 .. 3 ] == "\x3c\x00\x00\x00" data = uconvert ( data , 'utf-32le' , 'utf-8' ) elsif data [ 0 .. 3 ] == "\x00\x00\xfe\xff" data = uconvert ( data [ 4 .. - 1 ] , 'utf-32BE' , 'utf-8' ) elsif data [ 0 .. 3 ] == "\xff\xfe\x00\x00" data = uconvert ( data [ 4 .. - 1 ] , 'utf-32LE' , 'utf-8' ) elsif data [ 0 .. 2 ] == "\xef\xbb\xbf" data = data [ 3 .. - 1 ] else end return data end
Not configurable, hard coded in the xml files
Not configurable hard coded in the xml files
# EBCDIC # UTF-16BE # UTF-16BE with BOM # UTF-16LE # UTF-16LE with BOM # UTF-32BE # UTF-32LE # UTF-32BE with BOM # UTF-32LE with BOM # UTF-8 with BOM # ASCII-compatible
data