posted 17 years ago
I am passing an array of bytes, in both ways:
java to javascript
javascript to java
I am not sure how to do it accurately using 'String' that you mentioned, other than this strategy below:
1. Convert each byte into an int
e.g. 'a' to '97'
2. That way, in #1, I cover all scenarios, from -128 to +127
3. I concatenated all into a single string, with a delimiter like ':'.
e.g. 'a','b','c' to '97:98:99'
4. Pass it, and receiver easily recreates a 100% copy of the array
Java and javascript as far as I know, doesnt have a standard that browsers or java engines are supposed to comply with, with regards to data conversion between them, on precise things like byte.
Let me know if you know any 100% reliable, easier way than what I designed?
[ October 17, 2008: Message edited by: Jesus Angeles ]