in reply to Reading in utf-8 txt file gives garbled data when printed as part of utf-8 html...
See also perlunicodebinmode(STDOUT,":utf8"); open(FILE,"<:utf8", "$file"); my @Lines = <FILE>; close(FILE); $page = "<html>". join("",@Lines) ."</html>"; print "Content-Type: text/html; encoding=utf-8\n\n"; print $page;
update: also perlio - and note that you should never set the :raw layer (i.e. use binmode(FILEHANDLE) - without a second argument) on a (unicode) text file unless you're sure you know what you're doing.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reading in utf-8 txt file gives garbled data when printed as part of utf-8 html...
by isync (Hermit) on Aug 27, 2007 at 23:24 UTC | |
|
Re^2: Reading in utf-8 txt file gives garbled data when printed as part of utf-8 html...
by isync (Hermit) on Aug 27, 2007 at 23:06 UTC |