$buffer-encoding(5)$buffer-encoding - Buffer file encoding
$buffer-encoding "encoding"
$buffer-encoding is the encoding of the current buffer's file, the name of a single byte code page defined by set-char-mask(2) flag C, normally with code-page-define(3), or in a Unicode build one of:
utf8
utf16le, utf16be
utf32le, utf32be
followed by -bom when the file starts with a byte order mark, e.g. utf16le-bom. When set the code page must exist, the names are case sensitive; a code page name cannot start with utf so the two never clash.
A Unicode build detects the encoding when reading a file, a file which is not Unicode being read with the current code page, and writes the file back in the buffer's encoding, so a file stays byte identical. Setting a different encoding converts the file when next saved; a re-read of the file then uses it rather than detecting the encoding again, so a file read with the wrong code page can be fixed by setting the right one and re-reading it. A new buffer is utf8.
Other builds set it to the code page current when the file was loaded, "" for a new buffer; setting it changes the code page recorded but the text is not converted, an empty value is allowed.
Ref: $buffer-encoding(5) File: m5var099.5 Date: 2026/10/10
(c) Copyright JASSPA 2026