http resonse.write replaces \n with newline #7612
Replies: 1 comment
-
Posted at 2019-08-07 by @gfwilliams (Thanks for sticking the post in here!) Please can you post up some minimal example code that does this? Espruino will happily serve up pictures/etc that contain basically random characters, so I'd imagine it is something in the code. Posted at 2019-08-07 by maze1980 I've stripped down my code, same error:
Posted at 2019-08-07 by Robin Wed 2019.08.07 Isn't an escaped backslash, the backslash character, so the output is as it should be? (so we see a backslash followed by the letter n - L24) Posted at 2019-08-07 by AkosLukacs Yepp, that's working as it should work. You would get the same result in every other environment with the same escaping rules. Just try it in a browser console :) Posted at 2019-08-07 by maze1980 I see where my error is. In nodejs I can load files directly from disc. In Espruino I load my files from the flash using the storage module. And this is read back as string, according to the docs. So my example was actually too short, but the hint regarding strings handling helped. Thanks. My fix will be to pre-process the files before storing them to flash, escaping \n etc. Posted at 2019-08-08 by @gfwilliams Glad it's sorted! There's actually a tool online at http://espruino.com/File+Converter that might help you - just upload a file and it'll convert it to a form that is pre-escaped and ready for use. There was a plan to add a filesystem organiser to the Web IDE which might help with this sort of thing in future. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2019-08-07 by maze1980
Hi
I have a little web server, trying to send \n, \r, \t, \0 .
But it's being replaced newline, removed, space, nothing.
While this is the expected behavior for console.log() or print() when sending this data to a client it should arrive at the client (as it does in nodejs), not being replace by something else.
Beta Was this translation helpful? Give feedback.
All reactions