Created
September 5, 2011 09:11
-
-
Save venj/1194512 to your computer and use it in GitHub Desktop.
Ruby version of parsexml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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