base64encode的一个问题

之前写程序把base64encode的数据提交到服务器,服务器端出现数据的+号被替换为空格的情况。

查了w3规范手册,原因是如下的编码规范中说的,所以服务器会在解码时把+号改为空格然后给到业务。

所以最好再做个urlencode/urldecode

参考:http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1

application/x-www-form-urlencoded  

This is the default content type. Forms submitted with this content type must be encoded as follows:

  1. Control names and values are escaped. Space characters are replaced by `+', and then reserved characters are escaped as described in [RFC1738], section 2.2: Non-alphanumeric characters are replaced by `%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks are represented as "CR LF" pairs (i.e., `%0D%0A').
  2. The control names/values are listed in the order they appear in the document. The name is separated from the value by `=' and name/value pairs are separated from each other by `&'.

猜你喜欢

转载自ciaos.iteye.com/blog/2242425
今日推荐