Skip to main content
Module

x/ddc_vim/deps.ts>fn.char2nr

Dark deno-powered completion framework for neovim/Vim
Latest
function fn.char2nr
import { fn } from "https://deno.land/x/ddc_vim@v4.3.1/deps.ts";
const { char2nr } = fn;

Return Number value of the first char in {string}. Examples:

char2nr(" ")            returns 32
char2nr("ABC")          returns 65

When {utf8} is omitted or zero, the current 'encoding' is used. Example for "utf-8":

char2nr("á")            returns 225
char2nr("á"[0])         returns 195

When {utf8} is TRUE, always treat as UTF-8 characters. A combining character is a separate character. nr2char() does the opposite. To turn a string into a list of character numbers:

let str = "ABC"
let list = map(split(str, '\zs'), {_, val -> char2nr(val)})

Result: [65, 66, 67]

Returns 0 if {string} is not a String.

Can also be used as a method:

GetChar()->char2nr()

Parameters

denops: Denops
string: unknown
optional
utf8: unknown

Returns

Promise<number>