# HG changeset patch # User Nattee Niparnan # Date 2014-09-30 02:09:45 # Node ID b08eea94d57b3f76d1786854b08e5deb36c33dcf # Parent 9eed5e5663145d08107d0d4271c4ed056339cbbe make java accept utf8 diff --git a/std-script/compile b/std-script/compile --- a/std-script/compile +++ b/std-script/compile @@ -111,7 +111,8 @@ #get the class name classname = 'DUMMY' source = Array.new - File.foreach(params[:source_file]) do |line| + File.foreach(params[:source_file],'r:UTF-8') do |line| + line.encode!('UTF-8','UTF-8',invalid: :replace, replace: '') md = /\s*public\s*class\s*(\w*)/.match(line) classname=md[1] if md source << line unless line =~ /\s*package\s*\w+\s*\;/ @@ -122,7 +123,7 @@ end end #system("cp #{params[:source_file]} #{classname}.java") - command = "#{JAVA_COMPILER} #{classname}.java" + command = "#{JAVA_COMPILER} -encoding utf8 #{classname}.java" system(command, err: params[:message_file]) if File.exists?(classname + ".class") File.open(params[:output_file],"w") {|file| file.write("#{classname}")} diff --git a/std-script/grade b/std-script/grade --- a/std-script/grade +++ b/std-script/grade @@ -129,5 +129,6 @@ file.puts peak_memory end +puts "#{all_score} #{all_comment}" log "score = #{all_score}\ncomment = #{all_comment}" log "max_runtime = #{max_runtime}\npeak_memory = #{peak_memory}"