chaos-lang / fs

Filesystem library of the Chaos language
GNU Lesser General Public License v3.0
0 stars 0 forks source link

fs.write() escaping problem #1

Open mertyildiran opened 3 years ago

mertyildiran commented 3 years ago

fs.write() escaping the string while writing into the file:

num fp = fs.open('ignored/writeme.txt', 'w')
fs.write(fp, 'You wrote me!\n')
fs.close(fp)

Contents of ignored/writeme.txt file:

You wrote me!\n

Expected:

You wrote me!
aqeeph commented 3 years ago

I faced a similar problem. While reading from the file, it was also printing \ n characters, which is undesirable. Similar problem and solution: https://stackoverflow.com/questions/16712115/java-how-read-a-file-line-by-line-by-ignoring-n

mertyildiran commented 3 years ago

@aqeeph we have functions like escape_the_sequences_in_string_literal and escape_string_literal_for_transpiler in the language's source that probably causing this bug. But we need to keep those functions and their usages as is. So this fs should mitigate the problem by probably having the inverse implementations of those functions.

It's not related to Java language, I believe you shared as an example but Java is off topic in here.