3.5 Bytes and Byte Strings
A byte is an exact integer between 0 and 255, inclusive. The byte? predicate recognizes numbers that represent bytes.
Examples: | ||||
|
A byte string is similar to a string—
Reading Strings in Reference: Racket documents the fine points of the syntax of byte strings.
Examples: | |||||||||||||
|
The display form of a byte string writes its raw bytes to the current output port (see Input and Output). Technically, display of a normal (i.e,. character) string prints the UTF-8 encoding of the string to the current output port, since output is ultimately defined in terms of bytes; display of a byte string, however, writes the raw bytes with no encoding. Along the same lines, when this documentation shows output, it technically shows the UTF-8-decoded form of the output.
Examples: | ||||||
|
For explicitly converting between strings and byte strings, Racket supports three kinds of encodings directly: UTF-8, Latin-1, and the current locale’s encoding. General facilities for byte-to-byte conversions (especially to and from UTF-8) fill the gap to support arbitrary string encodings.
Examples: | |||||||||||||||||
|
Byte Strings in Reference: Racket provides more on byte strings and byte-string procedures.