I have a form where people input some text, which is then incorporated
into an HTML snippet which appears in a textarea for them to copy &
paste into a web page.
People will be entering foreign language stuff as well as special
characters like copyright, so I have to be sure this is handled
properly.
I tried rawurlencode() but that results in HTML which displays the
encoding when they paste it into their web page. I tried htmlentities
but that gives different characters than what they typed when displayed
in the textarea. I also tried no encoding, which worked well, except
that it gets messed up when I try to write it to the database and I
have the same problem again when retrieving it.
"Cañon ©" is a good example.
htmlentities('Cañon ©') -> Cañon © in the textarea, displays on their
web page as Cañon ©