0

I am moving a PHP application to another server, and I have some issues with the character decoding:

Old server (CentOS with Plesk Panel):

echo htmlentities('ú'), ENT_QUOTES, 'UTF-8'); // Result ú
echo html_entity_decode('&uacute', ENT_QUOTES, 'UTF-8'); // Result ú <= expected

New server (Debian dedicated server, fresh install):

echo htmlentities('ú'), ENT_QUOTES, 'UTF-8'); // Result &uacute;    
echo html_entity_decode('&uacute', ENT_QUOTES, 'UTF-8'); // Result ú <= not expected
echo html_entity_decode('&uacute', ENT_QUOTES, 'ISO-8859-1'); // Result ú <= expected

Why is happening this? Maybe a server configuration problem?

Iker Vázquez
  • 507
  • 3
  • 19
  • 1
    You are sending the wrong charset specifier with your HTML output. – mario Oct 08 '14 at 11:48
  • Yes, but I want to know why the same function works as expected on one server and not on the new one. – Iker Vázquez Oct 08 '14 at 12:07
  • Why are you blaming the function? **Your** HTML output contains no charset= or encoding= attribute anywhere. If you send UTF-8 text but leave the html page or http headers to claim Latin-1, then they're not rendered incorrectly. – mario Oct 08 '14 at 14:43

1 Answers1

2

Try following

echo htmlentities('ú', ENT_QUOTES, 'UTF-8');
echo html_entity_decode('&uacute;', ENT_QUOTES, 'ISO-8859-1');
Bhumi Shah
  • 9,323
  • 7
  • 63
  • 104
  • If I test this lines on the new server the resutl is the expected, but if I test them on the old one I get the wrong result. I need to know why I have different results on both servers. – Iker Vázquez Oct 08 '14 at 12:09