租房小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
453 B

3 months ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.getStrBytesCount = void 0;
  4. function getStrBytesCount(str) {
  5. let bytesCount = 0;
  6. for (let i = 0; i < str.length; i++) {
  7. const c = str.charAt(i);
  8. if (/^[\u00-\uff]$/.test(c)) {
  9. bytesCount += 1;
  10. }
  11. else {
  12. bytesCount += 2;
  13. }
  14. }
  15. return bytesCount;
  16. }
  17. exports.getStrBytesCount = getStrBytesCount;