Andarian Posted June 8, 2009 Share Posted June 8, 2009 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... Quote Link to comment https://forums.phpfreaks.com/topic/161379-solved-how-do-i-deal-with-this-kind-of-user-input-%E2%80%99-for-instance/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 8, 2009 Share Posted June 8, 2009 This link discuss what HTML/Unicode values exist - http://en.wikipedia.org/wiki/Smart_quotes Quote Link to comment https://forums.phpfreaks.com/topic/161379-solved-how-do-i-deal-with-this-kind-of-user-input-%E2%80%99-for-instance/#findComment-851664 Share on other sites More sharing options...
Andarian Posted June 8, 2009 Author Share Posted June 8, 2009 I see they have an html entity translation, is there a PHP command that does this? something that translates ’ into ‘ Quote Link to comment https://forums.phpfreaks.com/topic/161379-solved-how-do-i-deal-with-this-kind-of-user-input-%E2%80%99-for-instance/#findComment-851684 Share on other sites More sharing options...
PFMaBiSmAd Posted June 8, 2009 Share Posted June 8, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/161379-solved-how-do-i-deal-with-this-kind-of-user-input-%E2%80%99-for-instance/#findComment-851689 Share on other sites More sharing options...
Andarian Posted June 8, 2009 Author Share Posted June 8, 2009 nice! thanks a lot for your help! Quote Link to comment https://forums.phpfreaks.com/topic/161379-solved-how-do-i-deal-with-this-kind-of-user-input-%E2%80%99-for-instance/#findComment-851733 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.