public static List <Gibo> Read(string path) { FileInfo fileInfo = new FileInfo(path); FileStream stream = new FileStream(path, FileMode.Open); MemoryStream ms = new MemoryStream((int)fileInfo.Length); byte[] byteArr = new byte[fileInfo.Length]; int val = stream.Read(byteArr, 0, (int)fileInfo.Length); string raw = Encoding.GetEncoding(51949).GetString(byteArr); List <Gibo> gibos = new List <Gibo>(); string[] lines = raw.Split('\n'); Dictionary <string, string> matchInfo = new Dictionary <string, string>(); List <Move> moves = new List <Move>(); bool commentFound = false; foreach (string _line in lines) { char[] trimLetters = { ' ', '', '\u001a' }; string line = _line.Trim('\r').TrimStart(trimLetters); //Console.WriteLine(line); //코멘트가 발견되면 if (line.Contains('{')) { commentFound = true; } //종료 문자가 나올 때까지 스킵한다. if (commentFound) { if (line.Contains('}')) { commentFound = false; } continue; } //모든 정보를 다 읽었으므로 저장한다. if (line.Length == 0) { //초기 셋팅 if (moves.Count > 0) { Gibo gibo = new Gibo(); gibo.matchInfo = matchInfo; gibo.moves = moves; gibos.Add(gibo); matchInfo = new Dictionary <string, string>(); moves = new List <Move>(); } } else if (line[0] == '[') { int tagEnd = line.IndexOf(' '); string tag = line.Substring(1, tagEnd - 1); int quBegin = line.IndexOf('\"'); int quEnd = line.LastIndexOf(']'); string content = line.Substring(quBegin + 1, quEnd - quBegin - 2); matchInfo[tag] = content; } //나머지 수순 else { string[] words = line.Split(' '); //<0>과 같은 문자를 제거한다. words = (from word in words where (word != "<0>" & word != "\r") select word).ToArray(); for (int k = 0; k < words.Length; k += 2) { string wordNum = words[k]; string wordMove = words[k + 1]; Move move; if (wordMove[0] == '한') //수쉼 { move = Move.Empty; } else { int fromY = int.Parse(wordMove[0].ToString()) - 1; int fromX = int.Parse(wordMove[1].ToString()) - 1; int nextIntIndex = 3; int toY; while (true) { bool foundNumber = int.TryParse(wordMove[nextIntIndex].ToString(), out toY); if (foundNumber) { toY--; break; } else { nextIntIndex++; } } int toX = int.Parse(wordMove[nextIntIndex + 1].ToString()) - 1; if (fromY == -1) { fromY = 9; } if (toY == -1) { toY = 9; } if (fromX < 0 || fromY < 0 || toX < 0 || toY < 0) { throw new Exception("???"); } move = new Move((sbyte)fromX, (sbyte)fromY, (sbyte)toX, (sbyte)toY); } moves.Add(move); } } } return(gibos); }