summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/luatexja/tool/jfm-readable.rb
blob: d60ad2efa59558089edbc81efc7567a25c3315b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#! /usr/bin/ruby
# -*- coding: utf-8 -*-

# The following script converts Unicode codepoints as 0x???? to real characters.

# USAGE: ruby __FILE__ ifile [> ofile]

def print_usage()
  print "USAGE: ruby ", __FILE__, "ifile [> ofile]\n"
end

if __FILE__ == $0
  # コマンドライン引数の処理
  if ARGV.length < 1
    print_usage()
    exit
  end
  ifile = ARGV[0]

  print "-- -*- coding: utf-8 -*-\n"
  open(ifile, "r").each_line{|line|
    line.gsub!(/0x[0-9a-fA-F]*/){|s| s.to_s + "(" + [s.to_i(0)].pack("U*") + ")"}
    print line
  }
end