Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8511927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:08:30+00:00 2026-06-11T04:08:30+00:00

This is an issue I have been dealing with for months, and I would

  • 0

This is an issue I have been dealing with for months, and I would really appreciate any help.

I am encoding a string and writing the output to MyFile.js using the function below. While debugging my example, char encodedCode[] displayed as integers has length 12 and these values: 97,0,108,101,114,116,40,34,80,114,0,105.

MyFile.js is correctly generated with the expected size and characters, as I can see from Notepad++.

MyFileServlet.java

public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
    res.setCharacterEncoding("iso-8859-1");
    res.setHeader("Content-Type", "text/javascript;charset=iso-8859-1");
    res.setHeader("Content-Disposition","attachment;filename=MyFile.js");
    PrintWriter printer=res.getWriter();
    char encodedCode[]=encode(req.getParameter("originalScript"));
    printer.write(encodedCode);
    printer.close();
}

However, when I try to run that MyFile.js with some debugging code (see below) from MyFile.html, I get different behaviour depending on the browser:

  • Chrome/Firefox: length 12 values 97,0,108,101,114,116,40,34,80,114,0,105
  • Internet Explorer 9: length 10 values 97,108,101,114,116,40,34,80,114,105

So IE is ignoring all the “0” characters. Why? Thank you very much

JSFIDDLE: http://jsfiddle.net/vnqL2/

Edit: I tried writing those bytes to an external binary file MyFile.xxx and reading them from Javascript/JQuery/Ajax/XMLHttpRequest and I still get the same issue with IE.

MyFile.html

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>My Page</title>
</head>
<body>
<script type="text/javascript" charset="iso-8859-1" src="MyFile.js">
</script>
</body>
</html>

MyFile.js

function d(a)
{
  a=(a+"").split("");
  var l=a.length,x=[l];
  alert(l);
  for(i=0;i<l;i++){
    x[i]=a[i].charCodeAt(0);
    document.write(x[i]);
  }
};
d("HERE GO THOSE BYTES HARDCODED");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:08:32+00:00Added an answer on June 11, 2026 at 4:08 am

    I do not know what is your purpose but NULL bytes inside strings are not legit.

    On the other hand you could easily reconstruct an array of bytes (integers) by transmitting the bytes as a comma seperated list of integers. Or another approach would be a json file.
    Example code:

    function d(a)
    {
      a=(a+"").split(",");
      var l=a.length,x=[l];
      alert(l);
      for(i=0;i<l;i++){
        x[i]=Number(a[i]);
        document.write(x[i]);
        document.write("<br>");
      }
      return x;
    };
    var ar = d("97,0,108,101,114,116,40,34,80,114,0,105"); // returns the byte array, length=12
    

    Test it here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been reading similar questions to this issue and have been able to get
I have been researching this issue pretty extensively and cannot seem to find an
I have been having this issue in iterating through an array of keys and
so i have been stuck with this issue for 3 weeks now and i
I have been trying to wrap my head around this issue for the past
I'm new with ruby and rails and have been struggling with this issue for
Good morning. I've been having this issue for some days and have been lokking
I know this issue has been touched on here but I have not found
I have been through numerous similar questions on this forum but my issue still
I've been struggling with this issue for a while now. I have OpenCart 1.5.2.1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.