Dir.getwd should return the internal encoding result not the filesystem encoding
if File.dirname return ascii encoding result,File.expand_path(File.dirname(f))will return the same encoding result,But expanded path may have some non_ascii chars,so change the File.dirname result to the internal encoding
use default internal encoding to generate message
change $LOADPATH to internal encoding And change script name to internal encoding
change the parser use internal encoding