1 public static int getLength(String s) {
 2     int length = 0;
 3     for (int i = 0; i < s.length(); i++) {
 4         int ascii = Character.codePointAt(s, i);
 5         if (ascii >= 0 && ascii <= 255) {
 6             length++;
 7         } else {
 8             length += 2;
 9         }
10     }
11     return length;
12 }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-12
  • 2021-10-05
  • 2021-11-24
  • 2022-12-23
相关资源
相似解决方案