Convert Strings And Bytes
Use /ork/cl_encoding to resolve an encoding by name, then convert between ABAP strings and byte strings.
DATA(utf8) = /ork/cl_encoding=>get( `UTF-8` ).
DATA(bytes) = utf8->get_bytes( `hello` ).
DATA(text) = utf8->get_string( bytes ).
Use Memory Streams
Memory streams implement input, output, and combined stream interfaces. They are useful for tests and for APIs that should not care whether the backing store is memory, a file, or another source.
DATA(stream) = /ork/cl_io_memory_stream=>s_new( ).
stream->write( bytes ).
stream->set_position( 0 ).
DATA(copy) = stream->get_content( ).
Copy, Read, And Write
Use the interface-specific methods to keep call sites honest: input streams can be read or copied, output streams can be written and flushed, and base streams expose position, length, and capability checks.
source->copy_to( destination ).
DATA(chunk) = source->read(
offset = 0
count = 1024
).
Check can_read, can_write, and can_seek before generic stream utilities assume a capability.
