Hello,
I have a text file encoded in utf-8.
i am using fopen/fgets/echo etc..
how do i display these utf8 characters from the file on the web?
I have tried different combinations of
header("Content-Type: text/html; charset=iso-8859-1");
header("Content-Type: text/html; charset=utf-8")
and
utf8_decode/utf8_encode functions
I can't seem to get the characters from the file to display as
non-giberish on the web.
if i set the charset=utf8, and type the unique characters in directly to
my document (hard coded) and save the document as utf8, then the
characters display properly on the web.
examples:
1) save file as utf-8, web produces correct characters
<?php
header("Content-Type: text/html; charset=utf-8");
?>
<HTML><BODY>
[type special characters here using russian keyboard layout]
</BODY></HTML>
2) save file as ASCI, web produces [giberish]
<?php
header("Content-Type: text/html; charset=iso-8859-1");
?>
<HTML><BODY>
<?php
echo utf8_decode(fgets($handle));
?>
</BODY></HTML>
3) save file as utf-8, web produces [giberish]
<?php
header("Content-Type: text/html; charset=utf-8");
?>
<HTML><BODY>
<?php
echo fgets($handle));
?>
</BODY></HTML>
Thanks for your help,
dK