Hi,
I'm trying to encode binary data to hexadecimal values and then writing them
to a file using mdm.FileSystem.saveFileHEX(). I could also use the pipe
delimiter method but while it works correctly, it is very slow on larger
files.
So here is my problem: The binary data gets encoded to a hexadecimal values
string from a ByteArray like this:
var data:String = "";
var byte:int;
while (true)
{
try
{
byte = byteArray.readUnsignedByte();
data += byte.toString(16).toUpperCase();
}
catch (e:EOFError)
{
break;
}
}
But the file ends up always having a few bytes less then the original and
some bytes order is messed up. For example a 25,159 bytes file is only
24,209 bytes large after this and if doing a trace of the original byteArray
and the string data / 2, the values aren't equal .
trace(byteArray.length); // 25159
trace(data.length / 2); // 24208.5
Obviously something is wrong with the way how I convert to hex data but I
don't know what. Can somebody with more byteArray experience give me hint
how to get this working?
Cheers,
Sascha
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com