Skip to main content
Module

x/denops_std/function/mod.ts>strchars

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

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>