I'm having troubles while printing the array values, they are originally encoded with ISO-8859-1 and when echoed they appear with "?". That's so annoying!
I have the charset defined to ISO-8859-15
$lang = array();
$lang['HOMEPAGE'] = 'âéíó';
echo $lang['HOMEPAGE'];
result: ????
Any hints?
It used to work, using the utf8_decode(); but doesn't seem to solve my problem.
EDIT:
I well, i defined the charset for ISO-8859-15, but i was incl开发者_JS百科uding the file with the "áúóá" characters, before the html header because of cookie interaction, tried to use ob_start to use cookies on the body but the errors remained, defined charset with header() function and worked well, other solution is:
echo iconv('ISO-8859-1', 'UTF-8', $lang['PARAGRAFO1']);
There are two encodings at work here:
The encoding of your text, in this case the source code.
The encoding of the webpage. Make sure it's set to ISO-8859-1 as well. Put this meta tag in the header of your HTML file to enforce an encoding:
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
If you want to output as UTF-8, I suggest you to add those on your initial php script
ini_set("default_charset", "UTF-8");
mb_internal_encoding("UTF-8");
Of course you can change to other char if needed.
精彩评论