R – writing out a null in javascript

asp-classicjscript

This question is in follow up to this one: write binary data using JavaScript on the server.

The problem there with just using Response.Write to write the string is that the string contains a null character which JavaScript recognizes as the end of the string.

The string I'm trying to write starts with the following (written here in character codes)

255 216 255 212 0 16 ...

JavaScript will only output the first 4 characters here, because it recognizes the 5th as a string terminator. Is there any way around this?


I should note that I really do have to write out the binary null… the output of this is pdf, so I can't change the output format.

Best Answer

What about base-64 encoding the data? You'll need to decode it of course.

Related Topic