(A beginner in Node JS.) I am reading a file in node js using fs.readFileSync(filename)
which returns a Buffer.
I've got two linked questions:
- I am guessing the program sees binary (0 & 1) data, and converts it to symbols once tell it how to encode the binary data. Is this correct?
For example, when the file is read, it returns the information in Hex codes, and can be transformed by reading it with the appropriated encoding, for example utf-8, if we know it.
- The file I am reading uses
readUint8()
from Buffer. An unsigned integer 8 bits long.
What encode will this use to transform the first 8 bits to a number?
Are there simple exercises to write a decoder for a very simple encoded file?