'c#'에 해당되는 글 6건

  1. 2014.08.28 일본어 전각 반각 변환하기
C#2014. 8. 28. 19:27

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.VisualBasic; //참조추가

namespace changeFullorHalfJananese
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            String strText = textBox1.Text;
            string strTextWide = Microsoft.VisualBasic.Strings.StrConv(strText, VbStrConv.Wide); //전각
            string strTextNarrow = Microsoft.VisualBasic.Strings.StrConv(strTextWide, VbStrConv.Narrow); //반각
            //MessageBox.Show("半角 : " + strTextNarrow + System.Environment.NewLine + "全角 : " + strTextWide);
            MessageBox.Show("半角 : " + strTextNarrow + "\r\n" + "全角 : " + strTextWide);
        }
    }
}

-----------------------------------------------------------------

char c;

int byteCount = System.Text.Encoding.UTF8.GetByteCount(new char[]{c});

if (byteCount > 1)

{

// 전각

}

else 

{

// 반각

}

Posted by 댓거리사랑