Writing null in javascript

This question comes up to the following: write binary data using JavaScript on the server .

The problem with the simple use of Response.Writewriting a string is that the string contains a null character, which JavaScript recognizes as the end of the string.

The line 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, because it recognizes the fifth as a line terminator. Is there any way around this?


I should note that I really need to write binary zero ... the output of this is pdf, so I cannot change the output format.

+1
source share
2 answers

What about a database encoding data? Of course you need to decrypt it.

0
source

You should be able to pass the null object directly to the Write function and output it just like an empty string, there should be no runtime errors. Thus, the following code will not return anything to the screen:

protected void Page_Load(object sender, EventArgs e)
{
    string str = null;
    Response.ContentType = "text/plain";
    Response.Write(str);
    Response.End();
}
0
source

Source: https://habr.com/ru/post/1722526/


All Articles