Closed GoogleCodeExporter closed 8 years ago
JavaScript characters use the Unicode character set, and charCodeAt can return
values up to 65,535. If the string you're encoding has values above 255 and you
bitwise AND those values with 0xFF, then you will be losing data.
So the things to consider are: 1) If your data is conceptually a series of
characters, then you should probably use UTF8.stringToBytes rather than
Binary.stringToBytes. Or 2), if your data is conceptually a series of bytes,
then there shouldn't be any values higher than 255, and you should find out why
there is.
Original comment by Jeff.Mott.OR
on 18 Jun 2010 at 5:38
We receive the data from XMLHttpRequest. The following tutorial shows that the
data needs to be ANDed with 0xff...
https://developer.mozilla.org/en/using_xmlhttprequest#Receiving_binary_data
You could argue that we need to do that ourself because that specification asks
us to do so. Or crypto-js could be helpful and accept the kind of strings XHR
returns. What do you think? I thought crypto-js should do it because the
application programmer might have problems controlling the part of character he
is not interested in.
Original comment by toni.ruo...@gmail.com
on 19 Jun 2010 at 8:07
So XHR gives me a byte string which is not clean. My options are: 1) write a
janitor function which creates a new clean byte string 2) write my own function
for turning an unclean byte string into a list of integers.
Option 1 is a bit tricky as javascript strings are immutable. Thus the
operation can not be done in place. Option 2 leads to code duplication. Maybe
the crypto-js function could have an option for taking a dirty byte string as
input?
Original comment by toni.ruo...@gmail.com
on 20 Jun 2010 at 11:23
Original comment by Jeff.Mott.OR
on 20 Jun 2010 at 9:11
Fixed in revision 301. Will be included in release v2.0.1.
Original comment by Jeff.Mott.OR
on 7 Mar 2011 at 4:04
Original issue reported on code.google.com by
toni.ruo...@gmail.com
on 18 Jun 2010 at 8:57