UrlEncode编码是什么?

Infocode蓝畅 互联网开发 804

什么是UrlEncode编码?

urlencode是一个函数,可将字符串以URL编码,用于编码处理。

URL编码(URL encoding),也称作百分号编码(Percent-encoding), 是特定上下文的统一资源定位符 (URL)的编码机制。

适用于统一资源标识符(URI)的编码,也用于为”application/x-www-form-urlencoded” MIME准备数据, 因为它用于通过HTTP的请求操作(request)提交HTML表单数据。

 UrlEncode编码是什么?
UrlEncode编码是什么?

 UrlEncode编码原理

将需要转码的字符转为16进制,然后从右到左,取4位(不足4位直接处理),每2位做一位,前面加上%,编码成%XY格式。

比如:

空格ASCII码是32,对应16进制是20,那么urlencode编码结果是:%20,但在新标准中空格对应的是+,见RFC-1738

比如:

中ASCII码是-10544,对应的16进制是D6D0,那么urlencode编码结果是:%D6%D0




请在浏览器中启用JavaScript来完成此表单。
请输入姓名或昵称
如果您有任何疑问、需要更多信息或希望与我们建立合作请留言
=
( function() { const style = document.createElement( 'style' ); style.appendChild( document.createTextNode( '#wpforms-17950-field_1-container { position: absolute !important; overflow: hidden !important; display: inline !important; height: 1px !important; width: 1px !important; z-index: -1000 !important; padding: 0 !important; } #wpforms-17950-field_1-container input { visibility: hidden; } #wpforms-conversational-form-page #wpforms-17950-field_1-container label { counter-increment: none; }' ) ); document.head.appendChild( style ); document.currentScript?.remove(); } )();
加载

回复

我来回复
  • 暂无回复内容

已关闭回复。