Posted by Chung Leong on 12/18/66 11:51
ngocviet wrote:
> I want to convert it to UTF-8 encoding
>
>
> Chung Leong wrote:
> > ngocviet wrote:
> > > I have a text like this: "Thuyền Và Biển"
> > > How to convert it to: "Thuyền Và Biển"
> > > Please help!
> >
> > What text char-set/encoding do you want the text to be?
You will have to do it manually using preg_replace_callback(), as I
don't believe html_entity_decode() is capable of decoding such
entities. Here're the basics:
$text = preg_replace_callback('/&#(d+);/',
'numeric_html_entity_replace', $text);
function numeric_html_entity_replace($m) {
$unicode = (int) $m[1];
$utf8 = /* encode the Uncode value */
return $utf8
}
The tricky part is converting the Unicode value to a UTF-8 string.
Navigation:
[Reply to this message]
|