import { encoding } from "https://deno.land/x/denops_std@v6.5.1/option/mod.ts";
Sets the character encoding used inside Vim. It applies to text in
the buffers, registers, Strings in expressions, text stored in the
viminfo file, etc. It sets the kind of characters which Vim can work
with. See encoding-names
for the possible values.
NOTE: Changing this option will not change the encoding of the
existing text in Vim. It may cause non-ASCII text to become invalid.
It should normally be kept at its default value, or set when Vim
starts up. See multibyte
. To reload the menus see :menutrans
.
This option cannot be set from a modeline
. It would most likely
corrupt the text.
NOTE: For GTK+ 2 or later, it is highly recommended to set 'encoding' to "utf-8". Although care has been taken to allow different values of 'encoding', "utf-8" is the natural choice for the environment and avoids unnecessary conversion overhead. "utf-8" has not been made the default to prevent different behavior of the GUI and terminal versions, and to avoid changing the encoding of newly created files without your knowledge (in case 'fileencodings' is empty).
The character encoding of files can be different from 'encoding'. This is specified with 'fileencoding'. The conversion is done with iconv() or as specified with 'charconvert'.
If you need to know whether 'encoding' is a multibyte encoding, you can use:
if has("multi_byte_encoding")
Normally 'encoding' will be equal to your current locale. This will
be the default if Vim recognizes your environment settings. If
'encoding' is not set to the current locale, 'termencoding' must be
set to convert typed and displayed text. See encoding-table
.
When you set this option, it fires the EncodingChanged
autocommand
event so that you can set up fonts if necessary.
When the option is set, the value is converted to lowercase. Thus you can set it with uppercase values too. Underscores are translated to '-' signs. When the encoding is recognized, it is changed to the standard name. For example "Latin-1" becomes "latin1", "ISO_88592" becomes "iso-8859-2" and "utf8" becomes "utf-8".
Note: "latin1" is also used when the encoding could not be detected. This only works when editing files in the same encoding! When the actual character set is not latin1, make sure 'fileencoding' and 'fileencodings' are empty. When conversion is needed, switch to using utf-8.
When "unicode", "ucs-2" or "ucs-4" is used, Vim internally uses utf-8.
You don't notice this while editing, but it does matter for the
viminfo-file
. And Vim expects the terminal to use utf-8 too. Thus
setting 'encoding' to one of these values instead of utf-8 only has
effect for encoding used for files when 'fileencoding' is empty.
When 'encoding' is set to a Unicode encoding, and 'fileencodings' was not set yet, the default for 'fileencodings' is changed.
(default for MS-Windows: "utf-8", otherwise: value from $LANG or "latin1")