2017-06-19 24 views

回答

1

掃描COM標記的輸入流。唯一的技巧是你需要識別長度字段的標記並跳過它們。

+0

謝謝,這個回答讓我思考了正確的方向。 –

0

感謝user3344003上面我用node-binary此解決方案:

var binary = require('binary'); 

binary.parse(buffer) 
    // Scan for COM marker 0xfffe 
    .scan('precomment', new Buffer([0xff, 0xfe])) 

    // Get the next two bytes for the size of the comment field 
    .word16bu('size') 

    // Put the comment field in a buffer 
    .buffer('comment', 'size') 

    // Do something with the buffer 
    .tap(function (vars) { 
    console.log(vars.comment.toString('utf-8')); 
    }); 
相關問題