I have a mail thing that is sending out e-mails.
In the subject I had some problem with characters sometimes and I thought I solved it.
It looks fine when I try it in my webmail, but when I saw the subject in my iPhone it looked weird.
In the webmail it looks like this: It’s here now
But in the iPhone it looks like this: It's here now
In my code I solved it with the following code
$subject = html_entity_decode($subject);
But it doesn’t seem to solve it for the phone. I have also discovered that it looks weird in some e-mails that are being returned.
How should I do this to make it work?
What is the best way to check a form field so I input the chars the right way? First I sanitize the inputs. Then I would like chars like ’ or " and other that a user might add to be inserted into mysql the right way. What should I use? And what do I need to output these the right way later?
There isn’t a standard technique for managing this apart from writing your own snippets of code to manage what you need replaced, typically I would look for everything that could be a possible match and replace them with a UTF-8 equivalent character.
PHP maybe could be given a pass for not decoding the named entity – ' – because that particular named entity is non-standard, but there’s no excuse for it not to be able to decode the numeric code. Fortunately, despite this borked default behavior, it’s pretty easy to fix with the flags parameter.