Jump to content

htmlentities


Azu

Recommended Posts

Hello

I've tried all of the functions in PHP, and a lot of custom functions, and I can't find ANY that work right for UTF8.

 

They either don't display the trademark (™) sign right, or don't display common accented letters such (é) right.

 

What is a function for UTF8 that will display them all right?

Link to comment
https://forums.phpfreaks.com/topic/74951-htmlentities/
Share on other sites

many people below talk about using

<?php

    mb_convert_encode($s,'HTML-ENTITIES','UTF-8');

?>

to convert non-ascii code into html-readable stuff.  Due to my webserver being out of my control, I was unable to set the database character set, and whenever PHP made a copy of my $s variable that it had pulled out of the database, it would convert it to nasty latin1 automatically and not leave it in it's beautiful UTF-8 glory.

 

So [insert korean characters here] turned into ?????.

 

I found myself needing to pass by reference (which of course is deprecated/nonexistent in recent versions of PHP)

so instead of

<?php

    mb_convert_encode(&$s,'HTML-ENTITIES','UTF-8');

?>

which worked perfectly until I upgraded, so I had to use

<?php

    call_user_func_array('mb_convert_encoding', array(&$s,'HTML-ENTITIES','UTF-8'));

?>

 

Hope it helps someone else out

Link to comment
https://forums.phpfreaks.com/topic/74951-htmlentities/#findComment-378997
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.