js解码转码

Posted 微笑

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js解码转码相关的知识,希望对你有一定的参考价值。

1.

var data = \'Einvoice_cur_day:"30"\'
var encode = encodeURIComponent(data)//转码
console.log(encode)// Einvoice_cur_day%3A%2230%22
var decode = decodeURIComponent(encode)//解码
console.log(decode)// Einvoice_cur_day:"30"

2.

客户端这种编码格式传给你

js解码

var d = \'%7b%22TaxNo%22%3a%22910001200150542A%22%2c%22DiskNo%22%3a%22400444151032%22%2c%22Vesion%22%3a%221.0.0.1%22%2c%22Token%22%3a%22b6357f4c-e2e2-4f47-8a26-5e40b6283a51%22%2c%22Cinvoice_cur_day%22%3a%2210%22%2c%22Sinvoice_cur_day%22%3a%2220%22%2c%22Einvoice_cur_day%22%3a%2230%22%2c%22Minvoice_cur_day%22%3a%2225%22%2c%22Cinvoice_cur_month_rest%22%3a%22100%22%2c%22Sinvoice_cur_month_rest%22%3a%22150%22%2c%22Einvoice_cur_month_rest%22%3a%22500%22%2c%22Minvoice_cur_month_rest%22%3a%2210%22%7d\'
var decode = decodeURIComponent(d)
console.log(decode)//{"TaxNo":"910001200150542A","DiskNo":"400444151032","Vesion":"1.0.0.1","Token":"b6357f4c-e2e2-4f47-8a26-5e40b6283a51","Cinvoice_cur_day":"10","Sinvoice_cur_day":"20","Einvoice_cur_day":"30","Minvoice_cur_day":"25","Cinvoice_cur_month_rest":"100","Sinvoice_cur_month_rest":"150","Einvoice_cur_month_rest":"500","Minvoice_cur_month_rest":"10"}

 

以上是关于js解码转码的主要内容,如果未能解决你的问题,请参考以下文章

Js链接里的中文参数的转码和解码

js转码和解码兼容低版本火狐

js中post中文参数转码和解码

js base64的转码与解码

Java后台URL转码-Js编码和Java后台解码

js 如何给中文转码