mazey
    Preparing search index...

    Variable cutZHStringConst

    cutZHString: (
        str: string | null | undefined,
        len: number,
        options?: { dotText?: string; hasDot?: boolean },
    ) => string = truncateByWeightedLength

    Deprecated alias of truncateByWeightedLength.

    Type Declaration

      • (
            str: string | null | undefined,
            len: number,
            options?: { dotText?: string; hasDot?: boolean },
        ): string
      • Truncate a string by weighted UTF-16 length.

        Code units from U+0000 through U+00FF count as one; all other code units count as two. Optional truncation text is appended after the length limit. This does not measure bytes or rendered width and can split surrogate pairs.

        Usage:

        import { truncateByWeightedLength } from "mazey";

        const ret = truncateByWeightedLength("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.

    Use truncateByWeightedLength instead.