versace
versace

Reputation: 11

Trouble with encodings on my server, htmlentities shows wrong output by default

Here is my problem

<?php
 $aeo = 'å ä ö';
 echo htmlentities($aeo);
?> 

OUTPUT: (centos w/apache) [wrong]

&Atilde;&yen; &Atilde;&curren; &Atilde;&para;

[output with html:] å ä ö

OUTPUT SHOULD BE: (works perfectly on localhost with xampp on windows 7) [correct]

&aring; &auml; &ouml;

[output with html] å ä ö

I have no idea how to fix this and I have tried everything. Do you know how to possibly solve it? htmlentities isn't working correctly, apparently using wrong encoding or something like that... And the thing is, if I use htmlentities($aeo, ENT_QUOTES, 'UTF-8'); it works correctly (shows å ä ö as it should), but I have this in my php.ini: default_charset = "UTF-8" and this in my core.php: setlocale(LC_ALL, "sv_SE.UTF-8"); Thanks in advance

Upvotes: 0

Views: 185

Answers (1)

GZaffari
GZaffari

Reputation: 11

Unfortunately depends on the version of PHP. Newer versions use UTF-8 as default and older versions (less then 5.4.0) the default is ISO-8859-1 and is independent of the CHARSET value set in PHP.INI

Upvotes: 1

Related Questions