Skip to content

Instantly share code, notes, and snippets.

@suruseas
Created September 13, 2012 05:44
Show Gist options
  • Save suruseas/3712140 to your computer and use it in GitHub Desktop.
Save suruseas/3712140 to your computer and use it in GitHub Desktop.
\xxx\xxxの8進数形式で文字が表記されているテキストをそのままバイナリ変換して新たにファイルに保存する
while argv = ARGV.shift
File::open(argv, "r") do |rf|
File::open("#{File::realpath(rf)}.cnv", "w") do |wf|
while line = rf.gets
wf.puts line.gsub(/\\([0-9]+)/){
[$1.oct].pack("C*")
}
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment