Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ddc_vim/deps.ts>op.charconvert

Dark deno-powered completion framework for neovim/Vim8
Go to Latest
variable op.charconvert
import { op } from "https://deno.land/x/ddc_vim@v3.8.0/deps.ts";
const { charconvert } = op;

An expression that is used for character encoding conversion. It is evaluated when a file that is to be read or has been written has a different encoding from what is desired. 'charconvert' is not used when the internal iconv() function is supported and is able to do the conversion. Using iconv() is preferred, because it is much faster. 'charconvert' is not used when reading stdin --, because there is no file to convert from. You will have to save the text in a file first. The expression must return zero, false or an empty string for success, non-zero or true for failure. The possible encoding names encountered are in 'encoding'. Additionally, names given in 'fileencodings' and 'fileencoding' are used. Conversion between "latin1", "unicode", "ucs-2", "ucs-4" and "utf-8" is done internally by Vim, 'charconvert' is not used for this. 'charconvert' is also used to convert the viminfo file, if the 'c' flag is present in 'viminfo'. Also used for Unicode conversion. Example:

set charconvert=CharConvert()
fun CharConvert()
  system("recode "
        \ .. v:charconvert_from .. ".." .. v:charconvert_to
        \ .. " <" .. v:fname_in .. " >" .. v:fname_out)
  return v:shell_error
endfun

The related Vim variables are: v:charconvert_from name of the current encoding v:charconvert_to name of the desired encoding v:fname_in name of the input file v:fname_out name of the output file Note that v:fname_in and v:fname_out will never be the same. Note that v:charconvert_from and v:charconvert_to may be different from 'encoding'. Vim internally uses UTF-8 instead of UCS-2 or UCS-4.

The advantage of using a function call without arguments is that it is faster, see expr-option-function.

Encryption is not done by Vim when using 'charconvert'. If you want to encrypt the file after conversion, 'charconvert' should take care of this.

If the 'charconvert' expression starts with s: or <SID>, then it is replaced with the script ID (local-function). Example:

set charconvert=s:MyConvert()
set charconvert=<SID>SomeConvert()

Otherwise the expression is evaluated in the context of the script where the option was set, thus script-local items are available.

This option cannot be set from a modeline or in the sandbox, for security reasons.

(default "")

only available when compiled with the +eval feature

type

GlobalOption<string>