Skip to content

Instantly share code, notes, and snippets.

@heshed
Last active October 13, 2015 06:33
Show Gist options
  • Save heshed/c61b40bc8a7a4538a908 to your computer and use it in GitHub Desktop.
Save heshed/c61b40bc8a7a4538a908 to your computer and use it in GitHub Desktop.
josa.js
var process_josa = function(str) {
var font_cho = Array(
'ㄱ', 'ㄲ', 'ㄴ', 'ㄷ', 'ㄸ',
'ㄹ', 'ㅁ', 'ㅂ', 'ㅃ', 'ㅅ', 'ㅆ',
'ㅇ', 'ㅈ', 'ㅉ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' );
var font_jung = Array(
'ㅏ', 'ㅐ', 'ㅑ', 'ㅒ', 'ㅓ',
'ㅔ', 'ㅕ', 'ㅖ', 'ㅗ', 'ㅘ', 'ㅙ',
'ㅚ', 'ㅛ', 'ㅜ', 'ㅝ', 'ㅞ', 'ㅟ',
'ㅠ', 'ㅡ', 'ㅢ', 'ㅣ' );
var font_jong = Array(
'', 'ㄱ', 'ㄲ', 'ㄳ', 'ㄴ', 'ㄵ', 'ㄶ', 'ㄷ', 'ㄹ',
'ㄺ', 'ㄻ', 'ㄼ', 'ㄽ', 'ㄾ', 'ㄿ', 'ㅀ', 'ㅁ',
'ㅂ', 'ㅄ', 'ㅅ', 'ㅆ', 'ㅇ', 'ㅈ', 'ㅊ', 'ㅋ', 'ㅌ', 'ㅍ', 'ㅎ' );
var CompleteCode = str.charCodeAt(str.length-1);
var UniValue = CompleteCode - 0xAC00;
var Jong = UniValue % 28;
var josa="";
if (font_jong[Jong] === '') {
josa="로";
} else {
josa="으로";
}
return josa;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment