This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ElvishJerricco's profile picture

Binary HTTP handles

Started by ElvishJerricco, 26 September 2014 - 03:54 AM
ElvishJerricco #1
Posted 26 September 2014 - 05:54 AM
LuaJ has some bugs in the way it handles strings with characters above 127. It'd be nice if we could handle binary formats with the HTTP API without having to encode the data in base64 or something somewhere outside CC. Many places you might get binary data from won't provide a way to get the data in base64.
SquidDev #2
Posted 11 October 2014 - 09:39 AM
The same applies for file handles. It is always fun having to read a character at a time…
theoriginalbit #3
Posted 11 October 2014 - 09:44 AM
The same applies for file handles. It is always fun having to read a character at a time…
what?
SquidDev #4
Posted 11 October 2014 - 09:46 AM
The same applies for file handles. It is always fun having to read a character at a time…
what?

I'm pretty sure you cannot read binary files with readAll? I've always had trouble with it. Maybe its just me?
Bomb Bloke #5
Posted 11 October 2014 - 11:42 AM
I think you meant to say "bytes", as opposed to "characters".
theoriginalbit #6
Posted 11 October 2014 - 12:00 PM
I'm pretty sure you cannot read binary files with readAll? I've always had trouble with it. Maybe its just me?
no you can't. Java doesn't allow for it. Also I'm not completely sure why you'd ever want to do a readAll on a binary file. doing a readAll on a normal file returns a string, what would the readAll on a binary file return?
Lyqyd #7
Posted 11 October 2014 - 07:54 PM
The same thing string.byte returns when used on multiple characters.

It'd be nice to get readAll for binary file handles. Maybe it wouldn't be implemented on the io side of things, but having the option would be nice, since I imagine it'd be significantly faster to read it all entirely on the Java side rather than having to bounce back and forth a byte at a time. Not really a big deal either way, though.