# 获取字符串字节长度

lastUpdated: 2023-7-27

const getByteLen = str => {
  if (!str) return 0
  if (typeof str !== 'string') {
    str += ''
  }
  return str.replace(/[^\x00-\xff]/g, '01').length
}

# Comment area