Bug - Not A Bug strings don't load from file properly.

In it's simplest form, a string of the form "A\nB" will map_to_file() correctly, but when file_to_map()ed, only A is loaded into the string. Everything after the first line break seems to be ignored.

Is this intentional (and therefore up to the script author to correctly mask linebreaks) or a bug?
 

Bale

Minion
Yeah... I think that one is working properly.

If you're writing that string to a file, then the \n is just a character that is writing properly and mafia isn't trying to interpret it at all. On the other hand, if you file_to_map mafia has to try to interpret the data and it sees a single line in a file followed by a second line in a file.

I think that this falls into the heading of "doctor it hurts when I hit my head against the wall, what should I do? The doctor tell you to stop hitting your head against the wall."
 

StDoodle

Minion
Yup, run entity_encode() or possibly url_encode() (likely the former, but the latter would probably be fine) on your strings before saving them in maps is probably the best course of action. (And then, of course, decode them when reading in.)
 

Veracity

Developer
Staff member
file-to-map is defined to read individual lines of a file into individual map entries. Your newline character turns that string into two lines. You want a string with a newline? encode it on write and decode it on read.

This is working as intended.
 
Okay. I assumed (erroneously, apparently) that it was automatically doing some sort of conversion when saving to file, as (in Windows) just the "new line" character alone doesn't actually create a new line upon looking in the file as a human.

How dare cross-platform software function for more than just one line of Operating Systems.
 

Veracity

Developer
Staff member
(Macs and Linux use a single newline character as end-of-line. Only Windows requires a crlf.)

How dare cross-platform software function for more than just one line of Operating Systems.

Sarcasm is not appreciated. I've come this close -> <- to adding you to my ignore list before, but held off, when you started exhibiting a better attitude. Is this a reversion?
 
No. I had hoped that the obvious contradiction (and, as you pointed out, sarcasm) would make it apparent I was only joking.
 

Theraze

Active member
Even in the case of Windows, the newline character will cause a newline... depending on the editor you use. It's just less consistent than the various *nix OS.
 
Top