Bomb Bloke, on 17 December 2013 - 07:42 PM, said:
I ran into something similar when I started learning Java - tried using some function intended for writing text in order to write anything, and it stripped out all the characters it didn't consider to be standard Unicode. Or something. You'll notice you're only getting access to the first 128 symbols.
So if you want to write binary data, tell Lua you want to write binary data. If you want to write a whole bunch of data with a single function call, then write a function which breaks up your dataset into individual bytes, and call that!
Well i was trying to avoid that for a couple good reasons
first: there have been a few libraries that read binary files made in pure lua and sometimes can even deeply count on this functionality to be there (like one i wanted to encode files into base-64 so i could transfer binary files to/from my webserver with computercraft but the files kept being currupted when being encoded/decoded) and some of these libraries I have made myself
second: is there a way to read the responses from http.get() objects as a binary file reading a byte at a time? and if so is that even worth doing as it would take forever to loop a few kilobyte pic let alone a few megabyte one
Third: using a method like the one you describe is going to take up significantly more memory and processing power because of it (lua numbers are by default 4 byte floating point numbers but i believe that they can be assigned to be even 8 byte floating point numbers) meaning you suddenly explode a 1kb file into 4-8 kb in memory
i guess my point is that I am used to this functionality and I want to use it with CC too so if there is a way to do these things I would like to know (or have it fixed)
Edited by columna1, 17 December 2013 - 08:10 PM.