views:

21

answers:

3

Hi,

My website is set to UTF-8, do i have to set my forms also to utf-8 using the accept-charset for forms?

My guestbook for example allows multilanguage so my guestbook database table is utf8_unicode_ci and all my webpages use the same template so the encoding for all pages is utf-8, because i set the charset for my webpages as utf-8 do i have also set the form charset to utf-8 or no because i already set it for the webpage itself?

Reason why is i am converting my website to utf-8 and don't really want to go through all my site forms adding the form charset utf-8 attribute.

Thanks for any help

+1  A: 

Typically if the page is served explicitly with UTF-8, the form inputs will also be encoded in that character set.

Alex Mcp
Thanks Alex, this answers my question :)Thank you!
PHPLOVER
+1  A: 

It defaults to the character encoding/charset that the page was served with. You just need to ensure your response header has content-type with charset=utf-8

Jerome
Hi Jerome,It just says text/html .Although everything seems to work and show fine.What should i do to ensure the content type is charset-utf-8 ?I'm confused as i specidifed utf-8 in the meta tag Thanks
PHPLOVER
The browser should interpret that as UTF-8 then. The response header is always preferable to the meta tag as BalusC mentioned.
Jerome
+2  A: 

Almost every decent browser ignores the accept-charset attribute in favour of the encoding of the page with the form as it is definied in charset param of the Content-Type response header. The attribute works as far only in MSIE and even then, it is using it wrong. In MSIE running on Windows, any other value than UTF-8 would be interpreted as CP-1252.

Don't use this attribute. It's useless.

BalusC
Hi BalusC,I am confused, jerome said ensure the responce header says utf-8 mine says text/html, now i just looked and i know i can use:header('Content-type: text/html; charset=utf-8');but my confusion is why would i need to specify this when i have specified it in the meta tag as follows:<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />Confused ?Thanks
PHPLOVER
Response header != meta tag. The browser uses this information from the response header only and ignores the meta tag. The meta tag is only used when you opens the page from the local disk file system (and by *some* webcrawlers). Your `header()` looks fine. The `charset=utf-8` is in there. For more hints, head to [PHP UTF-8 Cheatsheet](http://developer.loftdigital.com/blog/php-utf-8-cheatsheet).
BalusC
Thanks will take a look at that link :)Thank you everyone.
PHPLOVER
You're welcome.
BalusC