import { decode } from "https://deno.land/x/denops_std@v6.5.0/buffer/mod.ts";
Decode raw binary content for string array for the bufnr
buffer
import type { Entrypoint } from "https://deno.land/x/denops_std@v6.5.0/mod.ts";
import * as fn from "https://deno.land/x/denops_std@v6.5.0/function/mod.ts";
import { decode, open, replace } from "https://deno.land/x/denops_std@v6.5.0/buffer/mod.ts";
export const main: Entrypoint = async (denops) => {
await open(denops, "README.md");
const bufnr = await fn.bufnr(denops);
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
.
Returns
Promise<DecodeResult>