Blockland Forums > Modification Help
How might one convert a BINARY FILE to a base64 string?
Space Guy:
That method would also remove characters 0x0A (line feed) or 0x0D (carriage return) if you're just appending each "line" read from the file so you wouldn't know which character is being removed each time. (or both, Notepad generates newlines with one of each CR-LF)
Lugnut:
so could I do this:
while(!%file.isEOF())
%filecontents = %filecontents @ %file.readline() @ "\r\n";
to solve the 0x0A and 0x0D problem?
Could I do something magical like this to try to work around the 0x00 part?
--- Code: ---// %l = letter in string
// %str = string, "%file.readline()"
%l = 0;
while(%l !$= "\r")
{
%character = getSubStr(%str, %l, %l+1);
if(%character $= "")
//Do something if the character is 0x00
}
--- End code ---
What if I converted it to base64, then DE-CONVERTED it to base64, then compared the resulting objects crc's?
if they aren't the same, then it should assume it stumbled across a 0x00 and can append it or something.
edit:I don't think I was clear, crc comparison would occur DURING the conversion to base64.
Ipquarx:
In order to PROPERLY do this, that is including all bytes including 0x00, you'd need to run a separate executable file on the local server of the computer that would do at the very least read the file, and somehow send blockland the file,
like sending a list of integers ranging from 0-255 representing each byte in the file.
If you want better speed, then you would have that executable put it in base64 as well.
Kalphiter:
--- Quote from: Lugnut1206 on June 15, 2012, 12:13:26 PM ---Could I do something magical like this to try to work around the 0x00 part?
--- Code: ---// %l = letter in string
// %str = string, "%file.readline()"
%l = 0;
while(%l !$= "\r")
{
%character = getSubStr(%str, %l, %l+1);
if(%character $= "")
//Do something if the character is 0x00
}
--- End code ---
--- End quote ---
No, because 0x00 can never be stored.
Lugnut:
--- Quote from: Ipquarx on June 15, 2012, 05:35:49 PM ---In order to PROPERLY do this, that is including all bytes including 0x00, you'd need to run a separate executable file on the local server of the computer that would do at the very least read the file, and somehow send blockland the file,
like sending a list of integers ranging from 0-255 representing each byte in the file.
If you want better speed, then you would have that executable put it in base64 as well.
--- End quote ---
god damn it.