Skip to content

Instantly share code, notes, and snippets.

@venj
Created September 5, 2011 09:11
Show Gist options
  • Save venj/1194512 to your computer and use it in GitHub Desktop.
Save venj/1194512 to your computer and use it in GitHub Desktop.
Ruby version of parsexml
#!/usr/bin/env ruby
def parse(f)
buffer = ""
open(f) { |file| file.seek 0x404;file.each_byte {|c| buffer << (0xff - c).chr} }
rindex = buffer.rindex(/<\/word>/) + "</word>".size
open(f.sub(".ydic", ".xml"), "w+").write(buffer[0...rindex].gsub("</word>", "</word>\n"))
end
(puts "Usage: #{File.basename $0} dict_file_1 [...]";exit 1) if ARGV.size < 1
ARGV.each { |f| parse f }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment