Re: Best way to encode?

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

 



Are you talking about page encoding? if so try utf8 on the pae with the form. (<meta http-equiv="Content-Type" content="text/html;charset= utf-8" />) it handles just about any language for input. and as long as you don't want to do a search on the input it can go right into the database (table character_set = utf8) for later extraction and display on a utf8 page.

if you're talking about encoding to "hide" the data - use base64_encode and base64_decode.

Respectfully,
Ligaya Turmelle


Brian Dunning wrote:
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 ©
rawurlencode('Cañon ©') -> Ca%C3%B1on%20%C2%A9 in the textarea, displays on their web page as Ca%C3%B1on%20%C2%A9from 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