code: function getSize(string) {
    let total = 0
    for (let i = 0, len = string.length; i < len; i++) {
      const charCode = string.charCodeAt(i)
      if (charCode <= 0x007f) {
        total += 1
      } else if (charCode <= 0x07ff) {
        total += 2
      } else if (charCode <= 0xffff) {
        total += 3
      } else {
        total += 4
      }
    }
  
    return total
  }
docs: 计算字符串字节数