• R/O
  • SSH
  • HTTPS

bchan: 提交


Commit MetaInfo

修訂652 (tree)
時間2015-03-11 00:44:17
作者ornse01

Log Message

fix for latest ruby.

Change Summary

差異

--- bchanf/trunk/src/tools/hmi_generator.rb (revision 651)
+++ bchanf/trunk/src/tools/hmi_generator.rb (revision 652)
@@ -1,7 +1,8 @@
1+# -*- coding: euc-jp -*-
12 #
23 # hmi_generator.rb
34 #
4-# Copyright (c) 2012 project bchan
5+# Copyright (c) 2012-2014 project bchan
56 #
67 # This software is provided 'as-is', without any express or implied
78 # warranty. In no event will the authors be held liable for any damages
@@ -25,12 +26,11 @@
2526
2627 require 'yaml'
2728 require 'erb'
28-require 'jcode'
2929
3030 def conv_euc_to_TCArray(str)
3131 ret = Array.new();
32- str.each_char do |x|
33- i = x.length - 1;
32+ str.encode("EUC-JP").each_char do |x|
33+ i = x.bytesize - 1;
3434 val = 0;
3535 x.each_byte do |ch|
3636 val += ch << (8 * i);
@@ -2849,9 +2849,7 @@
28492849
28502850 end
28512851
2852-$KCODE = "EUC"
2853-
2854-yaml = YAML.load_file(ARGV[0]);
2852+yaml = YAML.load(File.read(ARGV[0], encoding: 'EUC-JP:UTF-8'));
28552853 data = HMIData.new(yaml);
28562854
28572855 fname_header = yaml["generator"]["output_header"]
--- bchanf/trunk/src/tools/panel_generator.rb (revision 651)
+++ bchanf/trunk/src/tools/panel_generator.rb (revision 652)
@@ -1,3 +1,4 @@
1+# -*- coding: euc-jp -*-
12 #
23 # panel_generator.rb
34 #
@@ -25,12 +26,11 @@
2526
2627 require 'yaml'
2728 require 'erb'
28-require 'jcode'
2929
3030 def conv_euc_to_TCArray(str)
3131 ret = Array.new();
32- str.each_char do |x|
33- i = x.length - 1;
32+ str.encode("EUC-JP").each_char do |x|
33+ i = x.bytesize - 1;
3434 val = 0;
3535 x.each_byte do |ch|
3636 val += ch << (8 * i);
@@ -547,9 +547,7 @@
547547 fd.close
548548 end
549549
550-$KCODE = "EUC"
551-
552-yaml = YAML.load_file(ARGV[0]);
550+yaml = YAML.load(File.read(ARGV[0], encoding: 'EUC-JP:UTF-8'));
553551 data = PanelData.new(yaml);
554552
555553 fname_header = yaml["generator"]["output_header"]
Show on old repository browser