I have some data in a .glb file that starts off like this:
glTF ¤Ö @ JSON
I read the file using this code:
fs.readFile(file, (err, data) => {
if (err) console.log(err);
var message = {
"Message": "glb_string",
"Item": data
}
ws.send(JSON.stringify(message));
});
And send it off using a websocket connection to a client websocket server.
However, the Node buffer returned by fs.readFile looks like this:
Buffer@0x0000020A2BF455D0 67 6c 54 46 02 00 00 00 a4 d6 01 00 40 08 00 00 4a 53 4f 4e 7b ...
These values are incorrect. It gets simple letters correct in utf-8 form:
g(67) l(6c) T(54) F(46)
But once it gets to special characters like ¤ and Ö the buffer returns 00. The buffer should look like this:
Buffer@0x000001DD07B0E590 67 6C 54 46 02 20 20 20 C2 A4 C3 ...
or in decimal form:
103 108 84 70 2 32 32 32 164 214 1 32 64 8 32 32 74 83 79 78
2 is "stx start of text ctrl-b"
1 is "soh start of heading ctrl-a"
164 is ¤
214 is Ö
Not sure why the raw buffer that is being returned does not use the right values for those special characters. As a result the .glb file is not usable.
Thank you for any help.