Jump to content

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


Andarian

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.

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.