function StringUtil() { } StringUtil.printMonthDay = function(date) { // let dateTime = new Date(date); var a = date.split(" "); var d = a[0].split("-"); var t = "0:0:0".split(":"); if(a.count > 0) var t = a[1].split(":"); var dateTime = new Date(d[0],(d[1]-1),d[2],t[0],t[1],t[2]); return (dateTime.getMonth() + 1) + "월 " + dateTime.getDate() + "일"; } StringUtil.getRecordTextWithoutUnit = function(value) { let number = Math.floor(value); return NumberUtil.numberWithCommas(number); } StringUtil.getRecordTextWithUnit = function(value) { let number = Math.floor(value); let numberWithCommas = NumberUtil.numberWithCommas(number); if(isTypingGame()) return numberWithCommas + " 타"; else return numberWithCommas + " 점"; } StringUtil.getNumberStartWithZero = function(number, digitCount) { let n = number + ''; return n.length >= digitCount ? n : new Array(digitCount - n.length + 1).join('0') + n; } StringUtil.toKoreanAlphabets = function(text) { const cCho = [ 'ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ', 'ㄹ', 'ㅁ', 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅉ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' ]; const cJung = [ 'ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ', 'ㅔ', 'ㅕ', 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ', 'ㅚ', 'ㅛ', 'ㅜ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅠ', 'ㅡ', 'ㅢ', 'ㅣ' ]; const cJong = [ '', 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', 'ㄷ', 'ㄹ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅁ', 'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' ]; let cho, jung, jong; let str = text; let cnt = str.length; let chars = [], cCode; for (let i = 0; i < cnt; i++) { cCode = str.charCodeAt(i); // if (cCode == 32) { continue; } // 한글이 아닌 경우 if (cCode < 0xAC00 || cCode > 0xD7A3) { chars.push(str.charAt(i)); continue; } cCode = str.charCodeAt(i) - 0xAC00; jong = cCode % 28; // 종성 jung = ((cCode - jong) / 28 ) % 21; // 중성 cho = (((cCode - jong) / 28 ) - jung ) / 21; // 초성 chars.push(cCho[cho], cJung[jung]); if (cJong[jong] !== '') { chars.push(cJong[jong]); } } return chars; }; StringUtil.getUnicodeAlphabetCount = function(text) { let chars = StringUtil.toKoreanAlphabets(text); // console.log('char : ' + chars); let doubleJaum = [ 'ㄲ', 'ㅉ', 'ㄸ', 'ㄲ', 'ㅆ', 'ㄳ', 'ㄵ', 'ㄶ', 'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅄ' ]; let doubleMoum = [ 'ㅒ', 'ㅖ', 'ㅘ', 'ㅙ', 'ㅚ', 'ㅝ', 'ㅞ', 'ㅟ', 'ㅢ' ]; let alphabetCount = 0; let alphabet; for(let i = 0; i < chars.length; i++) { alphabet = chars[i]; if(doubleJaum.indexOf(alphabet) > -1 || doubleMoum.indexOf(alphabet) > -1) { // console.log('double alphabet : ' + alphabet); alphabetCount += 2; } else alphabetCount++; } // return chars; return alphabetCount; }; StringUtil.getScoreUnit = function(playingAppID) { if(playingAppID < 100) return " 타"; else return " 점"; }