shogi-server source
Revision | 3217ea40fa23133ba5f84f51617801f42025d5ff (tree) |
---|---|
Zeit | 2014-07-26 15:58:40 |
Autor | Daigo Moriwaki <daigo@debi...> |
Commiter | Daigo Moriwaki |
Fixed an encoding issue for mk_rate
@@ -679,7 +679,7 @@ def parse(line) | ||
679 | 679 | end |
680 | 680 | |
681 | 681 | if state == "abnormal" |
682 | - csa = CsaFileReader.new file | |
682 | + csa = CsaFileReader.new(file, "EUC-JP") | |
683 | 683 | if $options["abnormal-threshold"] == 0 || csa.ply <= $options["abnormal-threshold"] |
684 | 684 | return |
685 | 685 | end |
@@ -44,21 +44,21 @@ class CsaFileReader | ||
44 | 44 | attr_reader :start_time, :end_time |
45 | 45 | attr_reader :ply |
46 | 46 | |
47 | - def initialize(file_name) | |
47 | + def initialize(file_name, encoding="Shift_JIS:EUC-JP") | |
48 | 48 | @file_name = file_name |
49 | + @encoding = encoding | |
49 | 50 | @ply = 0 |
50 | 51 | grep |
51 | 52 | end |
52 | 53 | |
53 | 54 | def grep |
54 | - @str = File.open(@file_name, "r:Shift_JIS:EUC-JP").read | |
55 | + @str = File.open(@file_name, "r:#{@encoding}").read | |
55 | 56 | |
56 | 57 | |
57 | 58 | if /^N\+(.*)$/ =~ @str then @black_name = $1.strip end |
58 | 59 | if /^N\-(.*)$/ =~ @str then @white_name = $1.strip end |
59 | 60 | if /^'summary:(.*)$/ =~ @str |
60 | 61 | @state, p1, p2 = $1.split(":").map {|a| a.strip} |
61 | - return if @state == "abnormal" | |
62 | 62 | p1_name, p1_mark = p1.split(" ") |
63 | 63 | p2_name, p2_mark = p2.split(" ") |
64 | 64 | if p1_name == @black_name |