cheddar-lang / Cheddar

🧀 Cheddar, the language that works for you
cheddar.vihan.org
Apache License 2.0
28 stars 9 forks source link

fd#write(: Buffer) does not write #98

Open vihanb opened 7 years ago

vihanb commented 7 years ago

Version: v1.0.5

fd#write function when passed a Buffer, does not write any text to the file. However when passed a String object, it correctly writes to the file

schas002 commented 7 years ago

Just convert the Buffer to a string. All 😝

vihanb commented 7 years ago

@schas002 however the lovely UTF16 will mangle your bytes.

schas002 commented 7 years ago

Make something that enforces a 256-character encoding on strings. (Like, a Latin1String.) Then convert the Buffer to a string with that rule enforced and you're done. 😝

RikerW commented 7 years ago

The problem is that enforces a 256 character encoding. What if you want unicode?

schas002 commented 7 years ago

I suggested a new type.

schas002 commented 7 years ago

in "(Like, a Latin1String.)"

vihanb commented 7 years ago

That would be slow and it would be a buffer internally anyway.

vihanb commented 7 years ago

Strings are kinda like:

        Input          Internal       Output
  Source Encoding ->   UTF-16 -> Target Encoding

Meaning internally they are stored as UTF-16

vihanb commented 7 years ago

However Output is a buffer anyway

schas002 commented 7 years ago

So we may go only the hard path: using rubber ducks to resolve the problem.