More on autodetection

This commit is contained in:
Tony Garnock-Jones 2020-05-18 09:55:57 +02:00
parent af7c523513
commit 3eeaab375a
1 changed files with 20 additions and 0 deletions

View File

@ -945,6 +945,26 @@ syntax being used. In a network protocol supporting this kind of
autodetection, clients may transmit LF or `0xFF` to select text or
binary syntax, respectively.
Furthermore, if an application consistently uses `Record`s for its
top-level messages,[^records-and-nonatoms] eschewing `Atom`s in
particular, then autodetection of the encoding used for a given input
can be done as follows:
| First byte of encoded input | Encoding | Other conclusions |
| --- | --- | --- |
| `0x80`--`0x8F` | binary | `Record` (format B) |
| `0x28` | binary | `Record` (format C) |
| `0x05` | binary | annotated value (presumably a `Record`) |
| `0xFF` | binary | no-op; value will follow |
| --- | --- | --- |
| `0x7B` ("<") | text | `Record` |
| `0x40` ("@") | text | annotated value (presumably a `Record`) |
| `0x09`, `0x0A`, `0x0D`, `0x20` or `0x2C` | text | whitespace; value will follow |
[^records-and-nonatoms]: Similar reasoning can be used to permit
unambiguous detection of encoding when `Collection`s are allowed
as top-level messages as well as `Record`s.
## Appendix. Table of lead byte values
00 - False