简体中文
主题
获取中文字符串长度(中文算 2 个字节)。
import { getCHSLength } from 'js-cool'
function getCHSLength(string: string): number
string
number - 长度(中文=2,英文=1)。
number
getCHSLength('Hello世界') // 9 (5 + 2*2) getCHSLength('中文') // 4 getCHSLength('abc') // 3