Skip to main content
Module

x/denops_std/buffer/mod.ts>decode

📚 Standard module for denops.vim
Go to Latest
function decode
import { decode } from "https://deno.land/x/denops_std@v4.1.4/buffer/mod.ts";

Decode raw binary content for string array for the bufnr buffer

import { Denops } from "../mod.ts";
import * as fn from "../function/mod.ts";
import { decode, open, replace } from "../buffer/mod.ts";

export async function main(denops: Denops): Promise<void> {
  await open(denops, "README.md");
  const bufnr = (await fn.bufnr(denops)) as number;
  const data = await Deno.readFile("README.md");
  const { content } = await decode(denops, bufnr, data);
  await replace(denops, bufnr, content);
}

It follows Vim's rule to find a corresponding fileformat and fileencoding to decode the data if the one is not given by options.

Parameters

denops: Denops
bufnr: number
data: Uint8Array
optional
options: DecodeOptions = [UNSUPPORTED]