const proc = require('child_process').spawn('pbcopy');
const iconv = require('iconv-lite');
const name = '吉星高照';
function iconvDecode(str = '') {
return iconv.decode(Buffer.from(str, 'binary'), 'cp936');
}
function pbcopy(data) {
proc.stdin.write(iconvDecode(data));
proc.stdin.end();
return data;
}
pbcopy(name);
剪贴板的预期输出(在 macOS 上)应该吉星高照
是 ˱®
.