From 3217ea40fa23133ba5f84f51617801f42025d5ff Mon Sep 17 00:00:00 2001 From: Daigo Moriwaki Date: Sat, 26 Jul 2014 15:58:40 +0900 Subject: [PATCH] Fixed an encoding issue for mk_rate --- mk_rate | 2 +- utils/csa-filter.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mk_rate b/mk_rate index b540963..6090225 100755 --- a/mk_rate +++ b/mk_rate @@ -679,7 +679,7 @@ def parse(line) end if state == "abnormal" - csa = CsaFileReader.new file + csa = CsaFileReader.new(file, "EUC-JP") if $options["abnormal-threshold"] == 0 || csa.ply <= $options["abnormal-threshold"] return end diff --git a/utils/csa-filter.rb b/utils/csa-filter.rb index 0a863fe..72a8662 100755 --- a/utils/csa-filter.rb +++ b/utils/csa-filter.rb @@ -44,21 +44,21 @@ class CsaFileReader attr_reader :start_time, :end_time attr_reader :ply - def initialize(file_name) + def initialize(file_name, encoding="Shift_JIS:EUC-JP") @file_name = file_name + @encoding = encoding @ply = 0 grep end def grep - @str = File.open(@file_name, "r:Shift_JIS:EUC-JP").read + @str = File.open(@file_name, "r:#{@encoding}").read if /^N\+(.*)$/ =~ @str then @black_name = $1.strip end if /^N\-(.*)$/ =~ @str then @white_name = $1.strip end if /^'summary:(.*)$/ =~ @str @state, p1, p2 = $1.split(":").map {|a| a.strip} - return if @state == "abnormal" p1_name, p1_mark = p1.split(" ") p2_name, p2_mark = p2.split(" ") if p1_name == @black_name -- 2.11.0