print "Content-type: text/html; charset=utf-8 ... set $out1 from java program ... print Encode::encode('utf8', $out1);