node.js使用Ajax读取二进制数据

在BE服务器中,我发送binarystring到FE服务器。 Binarystring在responseText中。

//So. I do this.\ xhr2.open('GET', url, true); xhr2.onload = function() { routeResponse = Buffer.from(xhr2.responseText, 'binary'); //init Buf = ''; //byte by byte output for (let i = 0; i < routeResponse.length; i++) { Buf += routeResponse.readUInt8(i).toString(16).toUpperCase(); Buf += ' '; } console.log(Buf); } 

但是在日志和原始的cgi文件中是不同的二进制数据。

左:console.log(Buf)/右:原始文件中的hex值。 ex)getRoute.cgi

奇怪的是,只有某些值被输出为“FD”。 实际数据是'8B','8C'等等。

CGI文件格式:二进制/ Little Endian。

为什么某些数据被replace为“FD”请为我回答。

谢谢。