js 将base64编码进行urlencode编译函数

function urlencode (str) {  
  str = (str + '').toString();   
  return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').  
  replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');  
};

使用方法就是直接把base64编码后的图片信息。得到的字符串直接传给这个函数就可以了,会返回对应的urlencode编码;

一个在线编译的图片转换为base64编码的网站:记录一下

图片在线转换base64编码

猜你喜欢

转载自blog.csdn.net/m0_55315930/article/details/124398910