0

今日、node.exe を最新バージョンの 0.10.0 にアップグレードしましたが、奇妙な問題が見つかりました。中国語の文字を送信できません。コードは次のとおりです。

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('中文');

と:

//sub.js
process.on('message', function(m) {
console.log('CHILD got message:', m);
});

process.send({ foo: 'bar' });

master.js を実行すると、エラーが発生しました:

undefined:1 "d8-f" ^ SyntaxError: Pipe.channel.onread (child_process.js:335:28) の Object.parse (ネイティブ) での予期しないトークン

誰かアドバイスをいただけますか?</p>

4

1 に答える 1

2

再現できます。

これはバグのように見えますが (Node 0.8 では問題なく動作するため)、これは修正として機能します。

// master.js
...
n.send(new Buffer('中文'));

// sub.js
process.on('message', function(m) {
  console.log('CHILD got message:', new Buffer(m).toString());
});
....
于 2013-03-13T08:31:30.513 に答える