简体   繁体   中英

Is there byte sized data type in JavaScript?

I am currently trying to use Node to create a bitmap image. I have been using String.fromCharCode() to add bytes however I quickly realized this does not work. For example, if I wanted to create a file containing the hex values FF, it makes sense to me to use the code bellow.

test = String.fromCharCode(255);

When I examine the file it creates 2 bytes instead of one, 0xC3, 0XBF.

Is there a better way of doing this?

Use the Buffer object and then the readInt8() and writeInt8() function

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM