Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ddu_vim/deps.ts>fn.strchars

Dark deno-powered UI framework for neovim/Vim
Go to Latest
function fn.strchars
import { fn } from "https://deno.land/x/ddu_vim@v4.0.0/deps.ts";
const { strchars } = fn;

The result is a Number, which is the number of characters in String {string}. When {skipcc} is omitted or zero, composing characters are counted separately. When {skipcc} set to 1, Composing characters are ignored. strcharlen() always does this.

Returns zero on error.

Also see strlen(), strdisplaywidth() and strwidth().

{skipcc} is only available after 7.4.755. For backward compatibility, you can define a wrapper function:

if has("patch-7.4.755")
  function s:strchars(str, skipcc)
    return strchars(a:str, a:skipcc)
  endfunction
else
  function s:strchars(str, skipcc)
    if a:skipcc
      return strlen(substitute(a:str, ".", "x", "g"))
    else
      return strchars(a:str)
    endif
  endfunction
endif

Can also be used as a method:

GetText()->strchars()

Parameters

denops: Denops
string: unknown
optional
skipcc: unknown

Returns

Promise<number>