Function cutZHString

  • EN: Truncate string, Chinese characters count as 2 bytes.

    ZH: 截取字符串,中文算 2 个字节。

    Usage:

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

    Output:

    hello
    

    Parameters

    • str: string

      要截取的字符串

    • len: number
    • options: {
          dotText?: string;
          hasDot?: boolean;
      } = ...
      • Optional dotText?: string
      • Optional hasDot?: boolean

    Returns string

    返回截取后的字符串