Is form charset required?

2019-08-10 05:44发布

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 multi-language 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.

3条回答
乱世女痞
2楼-- · 2019-08-10 06:21

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

查看更多
我命由我不由天
3楼-- · 2019-08-10 06:23

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

查看更多
老娘就宠你
4楼-- · 2019-08-10 06:44

Almost every decent browser ignores the accept-charset attribute in favour of the encoding of the page with the form as it is defined 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.

查看更多
登录 后发表回答