添加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?

查看:96
本文介绍了添加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,请将<$

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的效果。但是,由于之前在该浏览器中 accept-encoding 讨论的问题,这仍然无法在IE中使用。

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). Personally, I don't bother.

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

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