in reply to Reading in utf-8 txt file gives garbled data when printed as part of utf-8 html...
What does the following show when you put "föö" in foo.txt?
use Data::Dumper qw( Dumper ); use HTML::Entities qw( encode_entities ); open(FILE, '<', 'file.txt'); binmode(FILE); my $content; { local $/; $content = <FILE>; } close(FILE); print "Content-Type: text/html; encoding=utf-8\n\n"; local $Data::Dumper::Useqq = 1; print '<pre>'; print encode_entities(Dumper($content)); print '</pre>'; print $content;
|
|---|
| 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:15 UTC | |
by ikegami (Patriarch) on Aug 27, 2007 at 23:35 UTC | |
by isync (Hermit) on Aug 28, 2007 at 09:54 UTC | |
by Anonymous Monk on Apr 21, 2009 at 23:49 UTC | |
by ikegami (Patriarch) on Apr 22, 2009 at 00:19 UTC |