From ae286cb6b7eafaf401e52e0757867d96cf707435 Mon Sep 17 00:00:00 2001 From: daekuk1 Date: Mon, 9 Feb 2026 16:45:46 +0900 Subject: [PATCH] =?UTF-8?q?function=20=EC=9C=84=EC=B9=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tracking/trackingManDetail.jsp | 65 ++++++++++--------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/WebContent/jsp/onl/transaction/tracking/trackingManDetail.jsp b/WebContent/jsp/onl/transaction/tracking/trackingManDetail.jsp index 66bece0..2e2a48c 100644 --- a/WebContent/jsp/onl/transaction/tracking/trackingManDetail.jsp +++ b/WebContent/jsp/onl/transaction/tracking/trackingManDetail.jsp @@ -914,40 +914,41 @@ $(document).ready(function() { // console.log("변환 완료:", parsedList); } - /** - * 문자열의 바이트 수 계산 (한글 2바이트, 영문/숫자 1바이트) - */ - function getByteLength(str) { - let byteCount = 0; - for (let i = 0; i < str.length; i++) { - const charCode = str.charCodeAt(i); - byteCount += (charCode >= 0xAC00 && charCode <= 0xD7A3) ? 2 : 1; - } - return byteCount; - } - - /** - * 문자열을 주어진 바이트 수만큼 패딩 - * @param {string} str - 원본 문자열 - * @param {number} targetBytes - 목표 바이트 수 - * @param {string} position - 'left' 또는 'right' (기본: 'right') - * @param {string} padChar - 패딩 문자 (기본: 공백) - * @returns {string} - 패딩된 문자열 - */ - function padByteString(str, targetBytes, position = 'right', padChar = ' ') { - const currentBytes = getByteLength(str); - - if (currentBytes >= targetBytes) { - return str; // 이미 목표 바이트 이상이면 그대로 반환 - } - - const paddingBytes = targetBytes - currentBytes; - const padding = padChar.repeat(paddingBytes); - - return position === 'left' ? padding + str : str + padding; - } }); +/** + * 문자열의 바이트 수 계산 (한글 2바이트, 영문/숫자 1바이트) + */ +function getByteLength(str) { + let byteCount = 0; + for (let i = 0; i < str.length; i++) { + const charCode = str.charCodeAt(i); + byteCount += (charCode >= 0xAC00 && charCode <= 0xD7A3) ? 2 : 1; + } + return byteCount; +} + +/** + * 문자열을 주어진 바이트 수만큼 패딩 + * @param {string} str - 원본 문자열 + * @param {number} targetBytes - 목표 바이트 수 + * @param {string} position - 'left' 또는 'right' (기본: 'right') + * @param {string} padChar - 패딩 문자 (기본: 공백) + * @returns {string} - 패딩된 문자열 + */ +function padByteString(str, targetBytes, position = 'right', padChar = ' ') { + const currentBytes = getByteLength(str); + + if (currentBytes >= targetBytes) { + return str; // 이미 목표 바이트 이상이면 그대로 반환 + } + + const paddingBytes = targetBytes - currentBytes; + const padding = padChar.repeat(paddingBytes); + + return position === 'left' ? padding + str : str + padding; +} +