Otter
Snippets
Otter
Upstream Otter 1.0.1 Tested
Encode and Decode Hex Strings
Transform between hexadecimal text strings and raw binary byte sequences.
Architecture & Runtime Preview
Otter 1.0.1Zero-dependency Otter 1.0.1 snippet (Text & Strings). Copy the parameterized template or run the self-contained example.
- 1Category: Text & Strings
- 2Attribution: Otter Core Language Spec (D115)
- 3Zero external pack dependencies — paste directly into any .ot file
Source Code (2 files)
rawBytes is bytes from hex ${hexInput}
decodedText is text from bytes rawBytes
encodedHex is hex from bytes rawBytes
hexInput is "4F74746572"
rawBytes is bytes from hex hexInput
decodedText is text from bytes rawBytes
say "Decoded text:" decodedText
if decodedText is not "Otter"
fail with "bytes from hex decode mismatch: expected Otter"
.
encodedHex is hex from bytes rawBytes
say "Encoded back:" encodedHex
if uppercase of encodedHex is not "4F74746572"
fail with "hex from bytes encode mismatch"
.
Installation & Usage
otter snippet inspect conv-bytes-hex
Copy template.ot directly into your .ot source file, or run example.ot with 'otter run example.ot'.