#!/usr/bin/perl use warnings; use strict; print "Content-type: text/html;charset=utf-8", "\n\n"; # open command and explicitly request utf-8 open (COMMAND,"-|:encoding(UTF-8)","java -classpath /usr/local/lib/CS.jar csearch/CorpusSearch 'HTMLQ((naġ Exists))") or die $!; my $out1 = join('',); # put all lines in one string binmode(STDOUT,":utf8"); # this marks the output as accepting utf8 print $out1;