map_to_file and file_to_map do not work correctly with strings which contain "\n"
KoLmafia's I/O functions fail with maps which contain strings with endline characters. Here's a little example:
output:
contents of text.txt:
I believe that newlines should be escaped in some way by KoLmafia before output to avoid this issue. For now I am escaping them myself.
KoLmafia's I/O functions fail with maps which contain strings with endline characters. Here's a little example:
Code:
boolean[string] m;
m["Hello\nGoodbye"] = true;
print("Original:");
foreach i in m
print(i + ": " + m[i]);
map_to_file(m, "text.txt");
clear(m);
print("After load");
file_to_map("text.txt", m);
foreach i in m
print(i + ": " + m[i]);
output:
Code:
> test1
Original:
HelloGoodbye: true
After load
Goodbye: true
contents of text.txt:
Code:
Hello
Goodbye true
I believe that newlines should be escaped in some way by KoLmafia before output to avoid this issue. For now I am escaping them myself.