diff --git a/src/main/webapp/resources/js/base/base.js b/src/main/webapp/resources/js/base/base.js index 7b395a9..9127454 100644 --- a/src/main/webapp/resources/js/base/base.js +++ b/src/main/webapp/resources/js/base/base.js @@ -29,6 +29,29 @@ function trim(s) { return s.replace(/^\s+/, "").replace(/\s+$/, ""); } +function strLength(str) { + let length = 0; + for (let i = 0; i < str.length; i++) { + let char = str.charCodeAt(i); + if (char <= 0x7F) { + length += 1; // 영문, 숫자, 일부 특수문자 + } else if (char <= 0x7FF) { + length += 2; + } else if (char <= 0xFFFF) { + length += 3; // 한글, 한자 등 + } else { + length += 4; // 이모지 등 + } + } + return length; +} + +const rem = { + base: parseFloat(getComputedStyle(document.documentElement).fontSize), + toPx(r) {return r * rem.base + "px";}, + fromPx(px) {return px / rem.base + "rem";} +}; + function isEmpty(v) { if (v == undefined || v == "undefined"