private string subMixString(string str, int subBytes)
    {
        int bytes = 0;   //   用来存储字符串的总字节数
        for (int i = 0; i < str.Length; i++)
        {
            if (bytes >= subBytes)
            {
                return str.Substring(0, i) + "……";
            }
            if (str[i] < 256)
            {
                bytes += 1;   //   英文字符的字节数看作1
            }
            else
            {
                bytes += 2;   //   中文字符的字节数看作2
            }
        }
        return str;
    }

相关文章:

  • 2021-07-27
  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
  • 2022-01-05
猜你喜欢
  • 2021-12-27
  • 2021-06-24
  • 2021-07-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2021-10-19
相关资源
相似解决方案