today i upgrade my node.exe to the latest version:0.10.0.But found a strange issue :can't send chinese char,the code is:
master.js:
//master.js
var cp = require('child_process');
var n = cp.fork(__dirname + '/sub.js');
n.on('message', function(m) {
console.log('PARENT got message:', m);
});
n.send('中文');
and:
//sub.js
process.on('message', function(m) {
console.log('CHILD got message:', m);
});
process.send({ foo: 'bar' });
when run master.js,an error occured:
undefined:1 "d8-f" ^ SyntaxError: Unexpected token at Object.parse (native) at Pipe.channel.onread (child_process.js:335:28)
does anyone can give some advise?
I can reproduce it.
Although it seems to be a bug (since it works okay in Node 0.8), this works as a fix:
// master.js
...
n.send(new Buffer('中文'));
// sub.js
process.on('message', function(m) {
console.log('CHILD got message:', new Buffer(m).toString());
});
....