I need to convert binary data to string.
I have this code:
var ws = new WebSocket(url);
ws.binaryType = 'arraybuffer';
ws.on('message', function(body) {
console.log(body);
console.log(body.toString());
});
And I got in console:
ArrayBuffer { byteLength: 266 }
[object ArrayBuffer]
From next code:
var ws = new WebSocket(url);
ws.on('message', function(body) {
console.log(body);
console.log(body.toString());
});
I got:
<Buffer 1f 8b 08 00 00 00 00 00 00 00 5d 92 c1 4b 1b 41 14 c6 bf 37 9b 51 82 84 a2 29 88 86 45 f1 50 2f 12 77 d5 54 14 d4 80 07 8f ... >
And something like this:
4ƿ7�Q���)��E�P/w�TԀ�JB[�B�S4�VA��Pza/"=ToC��[Ͻ�'Z�Z�^���7wXv�7�|�͛I@�^~��J�G��c�ʴ�Co�<��_70K1���~����iY31;��zc��<B���Q��~�+�F��_M(= N^I��}BU?U�̲��)���L���=,p��1\��8�[���[c�S]K����ܖIy.���Ơg\q��T���R�
���������8��#O;����f���n9z��CF:��Y��Xfl��--��U�QM�z�d֧�Ó�H� �}1yć�f�C����/2��"�TH���ԅʛ�w)E�R4
In browser I got this: