Created
February 24, 2014 03:45
-
-
Save czy88840616/9181649 to your computer and use it in GitHub Desktop.
windows下exec中文处理 gbk
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
String.prototype.each=function(i,fun){ | |
var index=0; | |
var that=this; | |
while(index<=that.length){ | |
(fun||function(){})(that.substr(index,i)) | |
index+=i; | |
} | |
} | |
var exec=require('child_process').exec; | |
var iconv=require('./iconv-lite'); | |
exec('ipconfig /all',{encoding:'hex'},function(e,r){ | |
var arr=[]; | |
r.each(2,function(data){ | |
arr.push(parseInt(data,16)); | |
}); | |
console.log(iconv.decode(new Buffer(arr), 'GBK')) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment