node.js - child_process.exec producing "♀" character -
i have simple child_process.exec statement , output (stdout) has "♀" character @ beginning reason
var exec = require('child_process').exec; exec('echo hi', function (err, stdout) { console.log(stdout); });
[
my node v0.12 , have iojs installed v2.3. i've tested both separately same result. i've tested in different consoles - cmd.exe, powershell, , git's sh.exe, same result.
is character supposed present? if not, might producing it?
according child_process
's documentation, object passed stdout
buffer object. need decode before printing out string.
i modified code demonstrate how that. symbol no longer appears in console.
var exec = require('child_process').exec; var stringdecoder = require('string_decoder').stringdecoder; var decoder = new stringdecoder('utf8'); exec('echo hi', function (err, stdout) { var message = decoder.write(stdout); console.log(message.trim()); });
for more detail string decoder, @ documentation here
Comments
Post a Comment