Jump to content

[SOLVED] How do I deal with this kind of user input " ’ " for instance


Recommended Posts

I have a function that, among other things, does htmlentities on user input.

 

It all works fine until someone enters a char like ’  (this is not a quote).

It happens when users first write their input in a word document then copy paste it to the text field and send the form.

 

I guess I can do preg_replace('`','\'',$input) but I will probably be missing some other annoying characters too...

 

 

 

 

 

The table that htmlentities uses (there is a get_html_translation_table() function that retrieves the values) does not contain those values. You would need to write a function to specifically convert those characters or retrieve the existing htmlentities table, add the additional characters and entity values to it, then use this new combined array to convert your data.

 

Edit: The strtr() function could be used if you choose to use the combined array method.

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.