&blen(4)&blen, &bmid, &batoi, &bitoa, &bhex, &hexb - Byte functions
&blen str
&bmid str
&batoi str
&bitoa num
&bhex str
&hexb hex
The byte functions work on the bytes of a string, which are the bytes the string would be written to a file as: in a Unicode build the UTF-8 bytes of each character, an invalid byte being that byte and a Nul character the byte 0. In other builds a byte is a character.
Bytes made into a string are decoded as a whole, in a Unicode build valid UTF-8 becomes characters, any other byte an invalid byte and 0 the Nul character.
&blen str
&bmid str index len
&batoi str
&bitoa num
&bhex str
&hexb hex
As each result is decoded on its own, joining the results of &bitoa gives invalid bytes rather than a UTF-8 character, &bmid of the joined string decodes them together:
&bmid &cat &bitoa 0xc3 &bitoa 0xa9 0 2
returns an 'e' acute (U+00E9) in a Unicode build, as does &hexb "c3a9".
&blen &lef @wl $window-col gives the byte offset of the cursor in the current line.
The following converts a string to its bytes in hexadecimal and back:
set-variable #l0 &bhex "Caf\xe9" set-variable #l1 &hexb #l0
Ref: &blen(4) File: m4fil039.4 Date: 2026/10/10
(c) Copyright JASSPA 2026