Created
June 13, 2013 03:47
-
-
Save xurenlu/5771126 to your computer and use it in GitHub Desktop.
nodejs-gbkUrlencode.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function encodeURIComponentUTF8toGBK(utf8String){ | |
var Iconv = require("iconv").Iconv; | |
var iconvLite=require("iconv-lite"); | |
var Buffer =require("buffer").Buffer; | |
var iconv = new Iconv("UTF-8","GBK"); | |
var res = iconv.convert(utf8String); | |
return encodeURIComponent(iconvLite.decode(res,"GBK")); | |
} | |
console.log( | |
encodeURIComponentUTF8toGBK("如何敷面膜") | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment