1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-19 10:26:17 +00:00
Files
seahub/frontend/src/components/search/constant.js
Michael An 88dc8d0cac run npm lint when open PR (#6375)
* 01 fix code warnings

* 02 change test.yml
2024-07-19 11:14:28 +08:00

20 lines
430 B
JavaScript

const getValueLength = (str) => {
let code;
let len = 0;
for (let i = 0; i < str.length; i++) {
code = str.charCodeAt(i);
if (code == 10) { // solve enter problem
len += 2;
} else if (code < 0x007f) {
len += 1;
} else if (code >= 0x0080 && code <= 0x07ff) {
len += 2;
} else if (code >= 0x0800 && code <= 0xffff) {
len += 3;
}
}
return len;
};
export { getValueLength };