자바스크립트로 한글 , 초성 중성 종성 분리 (음소분리)

<SCRIPT>

font_cho = Array(
'ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ',
'ㄹ', 'ㅁ', 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ',
'ㅇ', 'ㅈ', 'ㅉ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' );

font_jung = Array(
'ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ',
'ㅔ', 'ㅕ', 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ',
'ㅚ', 'ㅛ', 'ㅜ', 'ㅝ', 'ㅞ', 'ㅟ',
'ㅠ', 'ㅡ', 'ㅢ', 'ㅣ' );

font_jong = Array(
'', 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', 'ㄷ', 'ㄹ',
'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅁ',
'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' );



stringtest = "ㅤㅊㅠㄺ";
CompleteCode = stringtest.charCodeAt(0);
UniValue = CompleteCode - 0xAC00;

Jong = UniValue % 28;
Jung = ( ( UniValue - Jong ) / 28 ) % 21;
Cho = parseInt (( ( UniValue - Jong ) / 28 ) / 21);



alert( font_cho[Cho] );
alert( font_jung[Jung] );
alert( font_jong[Jong] );

</SCRIPT>

This program uses UNICODE 2.0. So this consists of Johap code. There are many code through ancient Hangul to recent one. Here, I used consonant existing in UNICODE 12593~12622 in decimal. And used vowel existing in UNICODE 12623~12643 in decimal. The first consonant consists of 19 words, and the vowel consists of 21 words, and the final consonant consists of 28 words. We can make Hangul Johap code in the following way,

(Hangul word) = 0xAC00 + chosung * 21 * 28 + jungsung * 28 + jongsung

44032 + (초성문자코드 * 588) + (중성문자코드 * 28) + (종성문자코드)로 조합

Posted by 퓨전마법사
,