javascript - "FF FF" is getting dumped as "FD" on some of the computers with Java Scripting API -


i facing issues java scripting api javascript on of pcs. after analyzing dumped file, noticed "ff ff" geeting printed "fd" on of pcs. below code snippet:

var outputfile = new randomaccessfile(f, "rw"); var byte_data_array = getmybytearraydata(somebytearray);  var data_string = new java.lang.string(byte_data_array); outputfile.writebytes(data_string); 

you're converting data bytes string without specifying encoding (which uses local-dependant platform default encoding), write file using writebytes() method documented in api doc discarding higher-order byte of each character.

what did expect? i'm surprised result has resemblance @ original data.

what should replace last 2 lines this:

outputfile.write(byte_data_array); 

and remember: bytes data, strings text, , if convert between them, need pay attention encoding used.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -