I would like to check if my sistem is able to handle file given by my customers. Due my customers can give me files in unknown encoding, i would like to create some test file in order to understand if file can be read without corruption.
my sistem run on nodejs 12.x
i read
i'm not able to understand well the differences between using encoding on writeFile
fs.writeFileSync("ascii.xml", Buffer.from("hello"), {'encoding':'ascii'})
encoding on toString
fs.writeFileSync("ascii.xml", Buffer.from("hello").toString(encoding="ascii"))
encoding on toString and also on File
fs.writeFileSync("ascii.xml", Buffer.from("hello").toString(encoding="ascii"), {'encoding':'ascii'})
encoding on Buffer and so on
fs.writeFileSync("ascii.xml", Buffer.from("hello",'ascii').toString(encoding="ascii"), {'encoding':'ascii'})
for example i'm not able to understand why this code
fs.writeFileSync("base64.xml", Buffer.from("string",'utf8').toString(encoding="base64"),{'encoding':'base64'})
produce a file containing the word "string"
but this
fs.writeFileSync("base64.xml", Buffer.from("string",'utf8').toString(encoding="base64"))
produce a file containing the base64 rappresentation of the word "string" : a base64 encoded file of a base64 encoded string generated from a base64 buffer built same character i put in the string?
thanks for any advice.