Closed GoogleCodeExporter closed 8 years ago
When you write non-ASCII characters directly into your page source, you need to
make sure you use a meta tag to set the charset. To see the difference it
causes, consider these two sources below.
/* No META charset */
<script type="text/javascript"
src="http://crypto-js.googlecode.com/files/2.0.0-crypto-sha256.js"></script>
<script type="text/javascript">
var m = "á";
alert(m.length); // alerts 2
alert(Crypto.SHA256(m)); // alerts
eb3e85d7fbf56104c8021681e68d771b9b9205b93e9219c8f81f60af703de381
</script>
/* Has META charset */
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript"
src="http://crypto-js.googlecode.com/files/2.0.0-crypto-sha256.js"></script>
<script type="text/javascript">
var m = "á";
alert(m.length); // alerts 1
alert(Crypto.SHA256(m)); // alerts
fb9778719d93551b1c88df5f1ab229f83ea30af112fc51017c9f0a383dcf6cb3
</script>
Original comment by Jeff.Mott.OR
on 17 Nov 2010 at 5:21
Original comment by Jeff.Mott.OR
on 18 Nov 2010 at 5:52
Original issue reported on code.google.com by
key...@gmail.com
on 17 Nov 2010 at 3:25