截取字符串,中文算 2 个字节
Usage:
const ret = truncateZHString('hello world', 5);console.log(ret); Copy
const ret = truncateZHString('hello world', 5);console.log(ret);
Output:
hello Copy
hello
要截取的字符串
返回截取后的字符串
截取字符串,中文算 2 个字节
Usage:
Output: