Bug - Not A Bug Special Characters from maps Redux

StDoodle

Minion
There's a chance this is one of those "just don't do that" situations, and if it is, please let me know. (& I'll pass the info on to zarqon!) :)

Currently, if I have a data file named "someFile.txt" containing special characters (say, "é"), it loads properly with file_to_map("someFile.txt",aggregate) but not with file_to_map("somefile.txt",aggregate).

I was under the impression case shouldn't matter for data files either; if it does, please mark "Not a Bug" and gimme a good slap.
 

Veracity

Developer
Staff member
Currently, if I have a data file named "someFile.txt" containing special characters (say, "é"), it loads properly with file_to_map("someFile.txt",aggregate) but not with file_to_map("somefile.txt",aggregate).
Why would you do this? If you know that the the file has an upper case letter in it, why would you not give the correct name? Why would you assume that files with different case characters in them would be the same, even though they are not the same on many platforms?
 

StDoodle

Minion
Heh, I ran into the problem because zlib saves your vars file using your name as-is, instead of changing it to all lower case or upper case. :)
 

Veracity

Developer
Staff member
By the way - I just fixed a cache-related bug in file_to_map: it would fail to read the special characters correctly the first time you read a file, although it would cache the data and subsequent calls to file_to_map would read them correctly.

Revision 8987. Tell me if this fixed it for you.
 

StDoodle

Minion
Hmm... my first test worked fine... then I created a new file, and it didn't work. Special characters are printing as the every-glorious square, and trying to look further into things using char_at()... KoLmafia looped up to character index 2,8177 showing no character data at all indices.

For reference, the code I used on the cli (using proper capitalization):
Code:
ash string [int] it;file_to_map("notAnotherTest.txt",it); foreach i,v in it { for c from 0 to (length(v) -1) { print(i+","+c+"="+char_at(v,c)); } print("Whole at " + i + " = " + v); }

It seems to sometimes work; and once it does, that file is fine. But no file seems to be reading properly the first time.
 

StDoodle

Minion
Harumph, so apparently, this only happens if I've loaded the file into notepad++ and saved changes... so I'm being an idiot and looking in the wrong direction.

Well, at least you're getting used to that, right? ;)

I'm unable to reproduce this problem if I last saved the file via map_to_file(), even if I log out afterwards and log back in. Setting notepadd++ to save text files in ANSII vs. UTF8 without BOM seems to help, but hasn't been fully tested (my problem of course, but any advice would be appreciated; if nothing else it should probably go up on the wiki). Argh.

Sorry for trouble. :(
 

Theraze

Active member
Check the file with a hex editor maybe, verify if it's turning tabs to spaces or changing CR/LF bits or something like that?
 
Top