Skip to main content
Module

x/denops_std/function/mod.ts>nr2char

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

Return a string with a single character, which has the number value {expr}. Examples:

nr2char(64)             returns "@"
nr2char(32)             returns " "

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

nr2char(300)            returns I with bow character

When {utf8} is TRUE, always return UTF-8 characters. Note that a NUL character in the file is specified with nr2char(10), because NULs are represented with newline characters. nr2char(0) is a real NUL and terminates the string, thus results in an empty string. To turn a list of character numbers into a string:

let list = [65, 66, 67]
let str = join(map(list, {_, val -> nr2char(val)}), '')

Result: "ABC"

Can also be used as a method:

GetNumber()->nr2char()

Parameters

denops: Denops
expr: unknown
optional
utf8: unknown

Returns

Promise<string>