添加accept-charset =“UTF-8”有什么好处吗?到HTML表单,如果页面已经在UTF-8? [英] Is there any benefit to adding accept-charset="UTF-8" to HTML forms, if the page is already in UTF-8?

查看:1328
本文介绍了添加accept-charset =“UTF-8”有什么好处吗?到HTML表单,如果页面已经在UTF-8?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于已经指定的页面(通过HTTP标头或元标记),要具有包含UTF-8字符集的Content-Type ...有一个好处是添加 accept-charset = UTF-8到HTML表单?

For pages already specified (either by HTTP header, or by meta tag), to have a Content-Type with a UTF-8 charset... is there a benefit of adding accept-charset="UTF-8" to HTML forms?

(我明白 accept-charset 属性在IE中被破坏为ISO-8859-1,但我没有听说过IE和UTF-8的问题,我只是问是否有一个好处是添加与UTF-8,以帮助防止无效

(I understand the accept-charset attribute is broken in IE for ISO-8859-1, but I haven't heard of a problem with IE and UTF-8. I'm just asking if there's a benefit to adding it with UTF-8, to help prevent invalid byte sequences from being entered.)

推荐答案

如果页面已被浏览器解释为UTF-8,请设置 accept-charset =utf-8不做任何事情。

If the page is already interpreted by the browser as being UTF-8, setting accept-charset="utf-8" does nothing.

如果将页面的编码设置为UTF-8在< meta> 和/或HTTP标头中,它将被解释为UTF-8,,除非用户故意转到View- >编码菜单并选择不同的编码,覆盖您指定的编码。

If you set the encoding of the page to UTF-8 in a <meta> and/or HTTP header, it will be interpreted as UTF-8, unless the user deliberately goes to the View->Encoding menu and selects a different encoding, overriding the one you specified.

在这种情况下, accept-encoding 将具有将用户设置提交编码回到UTF-8的效果,面对用户对页面编码的混乱。然而,这在IE中仍然不起作用,因为以前在该浏览器中使用 accept-encoding 讨论的问题。

In that case, accept-encoding would have the effect of setting the submission encoding back to UTF-8 in the face of the user messing about with the page encoding. However, this still won't work in IE, due the previous problems discussed with accept-encoding in that browser.

所以,IMO怀疑是否值得包括 accept-charset 来修复非IE用户故意破坏页面编码的情况(可能会在您的页面上更多地弄乱)

So it's IMO doubtful whether it's worth including accept-charset to fix the case where a non-IE user has deliberately sabotaged the page encoding (possibly messing up more on your page than just the form).

个人而言,我不打扰。

这篇关于添加accept-charset =“UTF-8”有什么好处吗?到HTML表单,如果页面已经在UTF-8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆