Jump to content

Trouble with htmlentities


c_shelswell

Recommended Posts

Hi I'm struggling a bit with htmlentities. I've got a text input and a user that wants to add greek symbols such as 'Σ'. After input I add it to the database as

 

htmlentities('Σ');

 

But what i'm getting in the database is: Σ when it should be

 	Σ

 

any ideas anyone?

Link to comment
Share on other sites

Look at the charset specified inside your head tages in your html/xhtml.

Mine is usually utf-8.

 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 

So if I'm using htmlentities - I specify the charset I'm using.

 

htmlentities(STRING, QUOTE STYLE, CHARSET)

 

In practice, it's:

 

$string = htmlentities($string,ENT_QUOTES,"utf-8");

 

Don't worry about the ENT_QUOTES part... that just means that you've chosen to change all single and double quotes into their respective html entities.

 

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.