public void AppendLine(string tag, int ver, string data, string rest)
        {
            var newLine = new YMLLine();

            newLine.tag  = tag;
            newLine.ver  = ver;
            newLine.data = data;
            newLine.rest = rest;
            lines.Add(newLine);
        }
        public void Read(string path)
        {
            var utf8NoBom = new UTF8Encoding(false);

            using (var reader = new StreamReader(File.OpenRead(path), utf8NoBom))
            {
                reader.Read();
                if (Equals(reader.CurrentEncoding, utf8NoBom))
                {
                    Console.WriteLine("No BOM: {0}", path);
                }
            }

            // ignore encoding
            var   raw = File.ReadLines(path, Encoding.GetEncoding(65001));
            Regex re  = new Regex("^ (?<tag>[^#\\:]+):(?<ver>\\d+)? (?<data>.+\"|.+)(?<rest>.+)?");

            foreach (var rawline in raw)
            {
                YMLLine newline = new YMLLine();
                Match   m       = re.Match(rawline);
                if (m.Success)
                {
                    if (m.Groups["ver"].Success)
                    {
                        string strVer = m.Groups["ver"].Value;
                        if (!int.TryParse(strVer, out newline.ver))
                        {
                            newline.ver = 0;
                        }
                    }
                    else
                    {
                        newline.ver = -1;
                    }

                    newline.tag  = m.Groups["tag"].Value;
                    newline.data = m.Groups["data"].Value;
                    if (newline.data.StartsWith("\"") && newline.data.EndsWith("\""))
                    {
                        newline.data = newline.data.Substring(1, newline.data.Length - 2);
                    }
                    if (m.Groups["rest"].Success)
                    {
                        newline.rest = m.Groups["rest"].Value;
                    }
                    newline.data = ProcessInput(newline.data);
                }
                else
                {
                    newline.data = rawline;
                }
                lines.Add(newline);
            }
        }
        public int GenHeader(string dummyLanguage)
        {
            if (lines.Count != 0)
            {
                return(-1);
            }

            YMLLine firstline = new YMLLine();

            firstline.data = "l_" + dummyLanguage + ":";
            lines.Add(firstline);
            return(1);
        }