1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-11-17 23:34:51 +00:00
CC-Tweaked/doc/events
Jonathan Coates 0c0556a5bc
Always use raw bytes in file handles
Historically CC has supported two modes when working with file handles
(and HTTP requests):

 - Text mode, which reads/write using UTF-8.
 - Binary mode, which reads/writes the raw bytes.

However, this can be confusing at times. CC/Lua doesn't actually support
unicode, so any characters beyond the 0.255 range were replaced with
'?'. This meant that most of the time you were better off just using
binary mode.

This commit unifies text and binary mode - we now /always/ read the raw
bytes of the file, rather than converting to/from UTF-8. Binary mode now
only specifies whether handle.read() returns a number (and .write(123)
writes a byte rather than coercing to a string).

 - Refactor the entire handle hierarchy. We now have an AbstractMount
   base class, which has the concrete implementation of all methods. The
   public-facing classes then re-export these methods by annotating
   them with @LuaFunction.

   These implementations are based on the
   Binary{Readable,Writable}Handle classes. The Encoded{..}Handle
   versions are now entirely removed.

 - As we no longer need to use BufferedReader/BufferedWriter, we can
   remove quite a lot of logic in Filesystem to handle wrapping
   closeable objects.

 - Add a new WritableMount.openFile method, which generalises
   openForWrite/openForAppend to accept OpenOptions. This allows us to
   support update mode (r+, w+) in fs.open.

 - fs.open now uses the new handle types, and supports update (r+, w+)
   mode.

 - http.request now uses the new readable handle type. We no longer
   encode the request body to UTF-8, nor decode the response from UTF-8.

 - Websockets now return text frame's contents directly, rather than
   converting it from UTF-8. Sending text frames now attempts to treat
   the passed string as UTF-8, rather than treating it as latin1.
2023-11-08 19:40:14 +00:00
..
alarm.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
char.md Relicense a couple of more files 2023-10-11 08:00:07 +01:00
computer_command.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
disk_eject.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
disk.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
file_transfer.md Always use raw bytes in file handles 2023-11-08 19:40:14 +00:00
http_check.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
http_failure.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
http_success.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
key_up.md Relicense a couple of more files 2023-10-11 08:00:07 +01:00
key.md Relicense a couple of more files 2023-10-11 08:00:07 +01:00
modem_message.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
monitor_resize.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
monitor_touch.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
mouse_click.md Relicense a couple of more files 2023-10-11 08:00:07 +01:00
mouse_drag.md Relicense a couple of more files 2023-10-11 08:00:07 +01:00
mouse_scroll.md Relicense a couple of more files 2023-10-11 08:00:07 +01:00
mouse_up.md Relicense a couple of more files 2023-10-11 08:00:07 +01:00
paste.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
peripheral_detach.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
peripheral.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
rednet_message.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
redstone.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
speaker_audio_empty.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
task_complete.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
term_resize.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
terminate.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
timer.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
turtle_inventory.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
websocket_closed.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
websocket_failure.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
websocket_message.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00
websocket_success.md Use standard Markdown link syntax for references 2023-08-24 11:23:33 +01:00