Last active
August 29, 2015 13:56
-
-
Save Knovour/8911841 to your computer and use it in GitHub Desktop.
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
var iconv = require('iconv-lite'); | |
var buf = iconv.encode('測試', 'big5'); // <buffer B4 FA B8 D5> | |
var bufLength = buf.length; | |
var test = ''; | |
for (var i = 0; i < bufLength; i++) | |
test += '%' + buf[i].toString('16').toUpperCase(); | |
// test = %B4%FA%B8%D5 |
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
var smsData = { | |
username: 'username', | |
password: 'password', | |
smbody: encodeToBig5('測試'), | |
dstaddr: 'dstaddr' | |
}; | |
// Create query | |
var query = unescape(querystring.stringify(smsData)); | |
// auerystring.stringify => 'username=username&password=password&smbody=%25B4%25FA%25B8%25D5&dstaddr=dstaddr' | |
// auerystring.stringify will encode '%' to '%25' | |
// use unescape to turn '%25' back | |
// unescape => 'username=username&password=password&smbody=%B4%FA%B8%D5&dstaddr=dstaddr' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment