Best way to encode?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 ©, but reads/writes OK from the database.
rawurlencode('Cañon ©') -> Ca%C3%B1on%20%C2%A9 in the textarea, displays on their web page as Ca%C3%B1on%20%C2%A9, but reads/writes OK from the database.
No encoding gives Cañon © in the textarea and displays on their web page as Cañon ©, but appears in the database as Cañon ©


How can I handle this so that what ultimately displays on their web page, after copying the HTML out of the textarea, matches what they typed in the form, and yet can be read & written from the database properly?

- Brian

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux