Description:
make java accept utf8
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r180:b08eea94d57b - - 2 files changed: 4 inserted, 2 deleted
@@ -111,7 +111,8 | |||||
|
111 | #get the class name |
|
111 | #get the class name |
|
112 | classname = 'DUMMY' |
|
112 | classname = 'DUMMY' |
|
113 | source = Array.new |
|
113 | source = Array.new |
|
114 | - File.foreach(params[:source_file]) do |line| |
|
114 | + File.foreach(params[:source_file],'r:UTF-8') do |line| |
|
|
115 | + line.encode!('UTF-8','UTF-8',invalid: :replace, replace: '') | ||
|
115 | md = /\s*public\s*class\s*(\w*)/.match(line) |
|
116 | md = /\s*public\s*class\s*(\w*)/.match(line) |
|
116 | classname=md[1] if md |
|
117 | classname=md[1] if md |
|
117 | source << line unless line =~ /\s*package\s*\w+\s*\;/ |
|
118 | source << line unless line =~ /\s*package\s*\w+\s*\;/ |
@@ -122,7 +123,7 | |||||
|
122 | end |
|
123 | end |
|
123 | end |
|
124 | end |
|
124 | #system("cp #{params[:source_file]} #{classname}.java") |
|
125 | #system("cp #{params[:source_file]} #{classname}.java") |
|
125 | - command = "#{JAVA_COMPILER} #{classname}.java" |
|
126 | + command = "#{JAVA_COMPILER} -encoding utf8 #{classname}.java" |
|
126 | system(command, err: params[:message_file]) |
|
127 | system(command, err: params[:message_file]) |
|
127 | if File.exists?(classname + ".class") |
|
128 | if File.exists?(classname + ".class") |
|
128 | File.open(params[:output_file],"w") {|file| file.write("#{classname}")} |
|
129 | File.open(params[:output_file],"w") {|file| file.write("#{classname}")} |
@@ -129,5 +129,6 | |||||
|
129 | file.puts peak_memory |
|
129 | file.puts peak_memory |
|
130 | end |
|
130 | end |
|
131 |
|
131 | ||
|
|
132 | + puts "#{all_score} #{all_comment}" | ||
|
132 | log "score = #{all_score}\ncomment = #{all_comment}" |
|
133 | log "score = #{all_score}\ncomment = #{all_comment}" |
|
133 | log "max_runtime = #{max_runtime}\npeak_memory = #{peak_memory}" |
|
134 | log "max_runtime = #{max_runtime}\npeak_memory = #{peak_memory}" |
You need to be logged in to leave comments.
Login now