My file was written with gedit as utf-8 under linux. I uploaded it as binary and when I look at it in the browser, all umlauts etc are ok (although I need to manually set my browser to encoding=utf-8..)
I use a small script to read in this .txt file and present it as html on a standard webpage which I serve as encoded in utf-8 (why the browser properly recognizes it this time). But the umlauts etc. on the page end up as garbled data then! ö is ö, ä is ä, ü is ü... Looks like a strange double-encoding bug, but I do not alter the data! Manually setting the browser to other encodings is of zero use.
open(FILE, "<$file");
binmode(FILE);
my @Lines = <FILE>;
close(FILE);
$page = "<html>". join("",@Lines) ."</html>";
print "Content-Type: text/html; encoding=utf-8\n\n";
print $page;
(simplified snippet)
---updated: filehandle is always "FILE"
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.