mazey
    Preparing search index...

    Function cutZHString

    • Truncate a string by weighted length, counting non-ASCII characters as two units.

      Usage:

      import { cutZHString } from "mazey";

      const ret = cutZHString("hello world", 5);
      console.log(ret);

      Output:

      hello
      

      Parameters

      • str: string | null | undefined

        String to truncate.

      • len: number

        Maximum weighted length.

      • options: { dotText?: string; hasDot?: boolean } = ...
        • OptionaldotText?: string

          Text appended when truncation occurs.

        • OptionalhasDot?: boolean

          Whether to append truncation text.

      Returns string

      The truncated string.