url编码,表单编码和mailto:编码 [英] url encoding, Form encoding and mailto: encoding

查看:164
本文介绍了url编码,表单编码和mailto:编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于与HTML相关的整个编码问题,我有些困惑.我没有在标头中引用字符集,也没有在XML序言中引用编码.我明白了.让我解释一下.

I am a little bit confused about the whole encoding issues related to HTML. I am not refering to the charset in the headers or encoding in the XML prologue. That I get. Lets me explain.

当"mailto:"与表单中的锚点或提交按钮一起使用时,空格被编码为%20",而换行/回车/新行/行尾"被编码为%0A.当在值"application/x-www-form-urlencoded"的表单上使用enctype属性时,空格被编码为"+",并且特殊字符,撇号,百分比和其他符号被转换为其ASCII十六进制等价物.值"application/x-www-form-urlencoded"是URL编码吗?那么,为什么第一个为%20",第二个为"+".

When the "mailto:" is used along with a anchor or a submit button in a form, white space is encoded as "%20" and "line feed/carriage return/new line/end of line" is encoded as %0A. While when the enctype attribute is used on a form with a value of "application/x-www-form-urlencoded" the white space is encoded as "+" and special characters, apostrophes, percentage and other symbols are converted to their ASCII HEX equivalents. Is the value "application/x-www-form-urlencoded" an URL Encoding? So why "%20" for the first one and "+" for the second.

"mailto:someone@someplace.com?cc=carbon@copy.com&bcc=blind@carbobcopy.org&subject=This%20is%20the%20subject&body=This%20is%20the%body%0AThis%20is%20the%20second%20paragraph"

在上面的示例中,主题中的空白编码为%20,而正文中的换行编码为%0A.

In the above example white space in the subject is encoded as %20 and new line in the body is encoded as %0A.

<form enctype="application/x-www-form-urlencoded"></form>

并且在上面的空白中将被编码为"+".我想念什么吗?

And in the above white space will be encoded to "+". Am I missing something?

谢谢.

推荐答案

URI(如您的mailto示例)应根据RFC 3986进行编码,该规范指定将空格编码为%20.

URIs (like your mailto example) should be encoded according to RFC 3986, which specifies that spaces are to be encoded as %20.

另一方面,根据HTML规范定义的规则,FORM数据的格式被编码为application/x-www-form-urlencoded. (例如,请参见HTML的第17.13.3.3节4.01规范.)这指定空格应翻译为+号.

The format of FORM data, on the other hand, is encoded as application/x-www-form-urlencoded according to the rules defined by the HTML specification. (See, for example, section 17.13.3.3 of the HTML 4.01 specification.) This specifies that spaces are to be translated as + signs.

因此,尽管URI和表单数据之间的百分比编码是相似的,但是空格字符的处理方式却有所不同.

Thus, while percent encoding is similar between URIs and form data, the space character is treated differently.

这篇关于url编码,表单编码和mailto:编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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