Did you know ... Search Documentation:
Pack canny_tudor -- prolog/swi/memfilesio.pl
PublicShow source

Bytes and octets

Both terms apply herein. Variable names reflect the subtle but essential distinction. All octets are bytes but not all bytes are octets. Byte is merely eight bits, nothing more implied, whereas octet implies important inter-byte ordering according to some big- or little-endian convention.

author
- Roy Ratcliffe
 with_output_to_memory_file(:Goal, +MemoryFile, +Options) is det
Opens MemoryFile for writing. Calls Goal using once/1, writing to current_output collected in MemoryFile according to the encoding within Options. Defaults to UTF-8 encoding.
 memory_file_bytes(?MemoryFile, ?Bytes:list) is det
Unifies MemoryFile with Bytes.
 put_bytes(+Bytes:list) is det
Puts zero or more Bytes to current output.

A good reason exists for putting bytes rather than writing codes. The put_byte/1 predicate throws with permission error when writing to a text stream. Bytes are not Unicode text; they have an entirely different ontology.

See also
- Character representation manual section at https://www.swi-prolog.org/pldoc/man?section=chars for more details about the difference between codes, characters and bytes.
 same_memory_file(+MemoryFile1, +MemoryFile2) is semidet
Succeeds if, and only if, two memory files compare equal by content. Comparison operates byte-by-byte and so ignores any underlying encoding.