Contents

[-]
1 power shell
2 c#
3 performance


1 power shell #

utf8.txt(utf-8 형식) 파일을 unicode.txt(unicode형식)으로 변환
powershell -Command "Get-Content d:\utf8.txt -Encoding UTF8 | Set-Content -Encoding UNICODE d:\unicode.txt"


2 c# #

/*
 * Created by SharpDevelop.
 * User: jaehak-lee
 * Date: 2016-03-28
 * Time: 오후 4:25
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Text;
using System.IO;

/*
namespace utf8_to_unicode
{
	public static class Program
	{	
		static void Main(string[] args)
        {
            using (StreamReader sr = new StreamReader(args[0], Encoding.UTF8))
            using (StreamWriter sw = new StreamWriter(args[1], false, Encoding.Unicode))
            {
                string line;
                int i = 1;
                while ((line = sr.ReadLine()) != null)
                {
                	if (i > 1) sw.Write("\r\n" + line);
                	else sw.Write(line);
                    i++;
                    
                    //sw.WriteLine(line);
                }
            }

        }
	}
}
*/


namespace utf8_to_unicode
{
	public static class Program
	{	
		static void Main(string[] args)
        {
            using (StreamReader sr = new StreamReader(args[0], Encoding.UTF8))
            using (StreamWriter sw = new StreamWriter(args[1], false, Encoding.Unicode))
            {
                string line;
                line = sr.ReadLine();
                if (line != null) sw.Write(line);
                
                while ((line = sr.ReadLine()) != null)
                {
                	sw.Write("\r\n" + line);
                }
            }

        }
	}
}
utf8_to_unicode.zip

3 performance #

ssis를 이용하여 1,552개의 파일을 10개로 병렬처리 해봤다. power shell로 했을 때는 약 13분, c#으로 했을 때는 22초 ㅜㅜ
power shell 안습이네