[C# , AS3 , ETC] 한글 유니 코딩 조합 원리


 





//참고 원문 : http://uuzazuk9.egloos.com/906488


한글 조합 공식 :
[{(초성)×588}+{(중성)×28}+(종성)]+44032

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TEST_Keyboard2
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);
            string result = ResultKorean("ㅇ", "ㅢ", "ㅇ"); //읭
            Console.WriteLine(result);
        }

        private string row_chosung = "ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ";
        private string row_jungsung = "ㅏㅐㅑㅒㅓㅔㅕㅖㅗㅘㅙㅚㅛㅜㅝㅞㅟㅠㅡㅢㅣ";
        private string row_jongsung = " ㄱㄲㄳㄴㄵㄶㄷㄹㄺㄻㄼㄽㄾㄿㅀㅁㅂㅄㅅㅆㅇㅈㅊㅋㅌㅍㅎ";

        private string ResultKorean(string chosung, string jungsung, string jongsung)
        {
            int chosungIndex = row_chosung.IndexOf(chosung);
            int jungsungIndex = row_jungsung.IndexOf(jungsung);
            int jongsungIndex = row_jongsung.IndexOf(jongsung);


            //공식
            int result = ((chosungIndex * 588) + ((jungsungIndex * 28) + jongsungIndex)) + 44032;


            char temp = Convert.ToChar(result);
            return temp.ToString();
        }

    }
}



간단한 유니코드의 연속 이라 .. 다른 언어에도 쉽게 적용할수 있을것 같다.
Yamecoder 야매코더_
C# 2011.11.21 17:07
Powerd by Tistory, designed by criuce
rss