Skip to main content
Module

x/denops_std/function/mod.ts>char2nr

📚 Standard module for denops.vim
Go to Latest
function char2nr
import { char2nr } from "https://deno.land/x/denops_std@v3.8.0/function/mod.ts";

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 With {utf8} set to 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] Can also be used as a |method|: GetChar()->char2nr()

Parameters

denops: Denops
string: unknown
optional
utf8: unknown

Returns

Promise<unknown>