tags:

views:

17

answers:

2

When I try to display Vietnamese characters with the following code:

<?php

$str = "Nghệ thuật cắm hoa vải";

//echo utf8_encode(html_entity_decode(($str)));
echo html_entity_decode($str);

//echo $str;

?>

I get Ngh�? thu�?t c??m hoa va?i as a result. Tried several option but couldn't make it. Any ideas?

A: 

Is the PHP script encoded in UTF-8? If it is, send a header indicating so:

header("Content-type: text/html; charset=utf-8");

Alternatively, do:

echo mb_convert_encoding($string, "HTML-ENTITIES", "UTF-8");
Artefacto
nope. still doesn't work
yken
@yken Then probably your PHP file is not saved in UTF-8. Make sure you save it as UTF-8 without BOM.
Artefacto
A: 

Works fine for me: http://codepad.org/uTmORRmz

Does your browser support Unicode?

Luca Matteis
Yes, it is. I also see it on the code pad, but when I run it locally it doesn't work. I using wamp for my php, could that be the issue?
yken