Linefeed in Webpages and Windows (heatshrink, espfs)
Posted: Fri Oct 07, 2016 11:05 am
Hello everyone
First time posting on this forum, hopefully not violating any netiquette
I'm using the eclipse windows framework by CHERTS and the esphttpd project as base for my webserver project. At the moment heatshrink is also enabled.
I observed some problems with reading (web) files from the espfs filesystem with espFsRead(), probably caused by different interpretation of the linefeed. My html files generated on windows use CR+LF as default for a new line.
Now the thing is espFsRead returns the the data length as I would expect: with CR+LF as 2 characters, in the data though there is only 1 character left (LF), but the length of the data string is still like with 2 characters. Unfortunately that causes additional junk characters at the end of the string.
I suspect the encoding/decoding process of heatshrink to cause this, but I am not completely sure. How should I deal with that? Can i define a flag somewhere for that case? Like a binary mode (was already looking for O_BINARY, but haven't found a solution in that case) or a config define in heatshrink?
I wouldn't mind at all if the read/decompressed data use LF as newline, but then at least I would suspect the returned length to be correct and/or the the string to be terminated at the correct position...
To be honest I have the feeling to overlook something trivial, as others would have had the same behaviour, but i couldn't find anything
Of course I could change the EOL settings in Notepad++ (already tested and it works) but i would prefer a universal windows compliant solution
First time posting on this forum, hopefully not violating any netiquette
I'm using the eclipse windows framework by CHERTS and the esphttpd project as base for my webserver project. At the moment heatshrink is also enabled.
I observed some problems with reading (web) files from the espfs filesystem with espFsRead(), probably caused by different interpretation of the linefeed. My html files generated on windows use CR+LF as default for a new line.
Now the thing is espFsRead returns the the data length as I would expect: with CR+LF as 2 characters, in the data though there is only 1 character left (LF), but the length of the data string is still like with 2 characters. Unfortunately that causes additional junk characters at the end of the string.
I suspect the encoding/decoding process of heatshrink to cause this, but I am not completely sure. How should I deal with that? Can i define a flag somewhere for that case? Like a binary mode (was already looking for O_BINARY, but haven't found a solution in that case) or a config define in heatshrink?
I wouldn't mind at all if the read/decompressed data use LF as newline, but then at least I would suspect the returned length to be correct and/or the the string to be terminated at the correct position...
To be honest I have the feeling to overlook something trivial, as others would have had the same behaviour, but i couldn't find anything
Of course I could change the EOL settings in Notepad++ (already tested and it works) but i would prefer a universal windows compliant solution