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
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
Share on other sites

Thank you but when I try that it gives me this error

XML Parsing Error: junk after document element
=/

 

And also I can't find that function in php.net.. it says it cannot find it.. is it a real function?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.