Note that there are some explanatory texts on larger screens.

plurals
  1. POSpecial character '\u0098' read as '\u02dc' using charCodeAt()
    primarykey
    data
    text
    <p>I am creating test.js from Java, as per below. Test.js implements function d(), that receives as parameter special character ˜ ('\u0098');</p> <p>Function d() should display the charCodeAt() of this special characters, that would be 152. However, it displays 732.</p> <p>Please note that <strong>characters 152 and 732 are both represented by special character ˜</strong>, as per below.</p> <p><a href="http://www.fileformat.info/info/unicode/char/098/index.htm" rel="nofollow">http://www.fileformat.info/info/unicode/char/098/index.htm</a></p> <p><a href="http://www.fileformat.info/info/unicode/char/2dc/index.htm" rel="nofollow">http://www.fileformat.info/info/unicode/char/2dc/index.htm</a></p> <p>How can I force function d() to display 152 instead of 732? (charset issue?). THANKS</p> <p><strong>TEST.JAVA</strong></p> <pre><code>public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { res.setHeader("Content-Type", "text/javascript;charset=ISO-8859-1"); res.setHeader("Content-Disposition","attachment;filename=test.js"); res.setCharacterEncoding("ISO-8859-1"); PrintWriter printer=res.getWriter(); printer.write("function d(a){a=(a+\"\").split(\"\");alert(a[0].charCodeAt(0));};d(\""); // Writes beginning of d() function printer.write('\u0098'); // Writes special character as parameter of d() printer.write("\");"); // Writes end of d() function printer.close(); } </code></pre> <p><strong>TEST.JS created by TEST.JAVA</strong></p> <pre><code>function d(a) { a=(a+"").split(""); alert(a[0].charCodeAt(0)); }; d("˜"); // Note special character representing '\u0098' </code></pre> <p><strong>TEST.HTML</strong></p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;&lt;/head&gt; &lt;body&gt; &lt;script type="text/javascript" charset="ISO-8859-1" src="test.js"&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload