Skip to main content
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@v2.3.0/deps.ts";
const { charconvert } = op;

{only available when compiled with the |+eval| feature} 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 or an empty string for success, non-zero 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. Encryption is not done by Vim when using 'charconvert'. If you want to encrypt the file after conversion, 'charconvert' should take care of this. This option cannot be set from a |modeline| or in the |sandbox|, for security reasons.