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
Post a Comment