Title: WriteBInaryFile from JS same way as C#
Tags: javascript;node.js
Question: I having trouble writing array from JS, Specially with decimal values which are greater then 100.
If i use  c# File.WriteAllBytes method i get different output then when I use nodejs appendFile
I am using appendFile and not writeFile because its within a loop.
I`ve taken hardcoded array for testing and this is what i got:
byte[] arr2 = new byte[] {78, 51, 49, 48, 48, 48, 85, 49, 164, 0, 67, 54, 52, 49, 53, 57, 52, 57, 52,
66, 52, 50, 49, 48, 69, 57, 70, 69, 55, 70, 50, 52, 70, 48, 69, 52, 70, 70,
50, 67, 67, 55, 50, 67, 69, 54, 53, 56, 66, 67, 53, 66};
File.WriteAllBytes(&quot;test&quot;, arr2);
const fsp = require(&quot;fs&quot;).promises;
const writeDataToFileFile = async (data: Buffer) =&gt; {
const appTempPath = app.getPath(&quot;temp&quot;);
const pathToWrite = path.join(appTempPath, &quot;test.bin&quot;);
await fsp.appendFile(pathToWrite, `${data}`);
const arr = [
78, 51, 49, 48, 48, 48, 85, 49, 164, 0, 67, 54, 52, 49, 53, 57, 52, 57, 52,
66, 52, 50, 49, 48, 69, 57, 70, 69, 55, 70, 50, 52, 70, 48, 69, 52, 70, 70,
50, 67, 67, 55, 50, 67, 69, 54, 53, 56, 66, 67, 53, 66,
logger.info(arr);
const bufferFromArr = Buffer.from(arr);
logger.info(bufferFromArr);
await writeDataToFileFile(bufferFromArr);
M problem with JS is the � which represents the value 164, when logging the buffer.
this is the buffer: N31000U1� C64159494B4210E9FE7F24F0E4FF2CC72CE658BC5B
c# file output: N31000U1₪.C64
JS file output: N31000U1ן¿½.C64
I figured out the c# converts the 164 into hex and then writes it, The question is how to achive this in JS
Comment: You can write the buffer directly, not via a template literal.  See [here](https://stackoverflow.com/questions/37489360/how-to-write-binary-not-utf-8-to-file)

Comment: Your`e right. Its also solved me the issue.



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2022:00:06/12/22', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><node.js>', 'Title': 'WriteBInaryFile from JS same way as C#', 'ViewCount': 24, 'id': 72590475, 'user_AboutMe': '', 'user_AccountId': 7409608.0, 'user_DisplayName': 'ATT', 'user_Reputation': 765.0, 'user_Views': 107.0, 'user_id': 5637397.0}}