Reading bytes from a JavaScript string
<p>I have a string containing binary data in JavaScript. Now I want to read, for example, an integer from it. So I get the first 4 characters, use <code>charCodeAt</code>, do some shifting, etc. to get an integer.</p>

<p>The problem is that strings in JavaScript are UTF-16 (instead of ASCII) and <code>charCodeAt</code> often returns values higher than 256. </p>

<p>The <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String/charCodeAt" rel="nofollow">Mozilla reference</a> states that "The first 128 Unicode code points are a direct match of the ASCII character encoding." (what about ASCII values > 128?).</p>

<p>How can I convert the result of <code>charCodeAt</code> to an ASCII value? Or is there a better way to convert a string of four characters to a 4 byte integer?</p>
