public void DebugStringAdd(string str)
 {
     /*if (importResult == null)
      * {
      * importResult = "";
      * }*/
     //importResultString += str + "\n";
     importResult.AddString(str);
 }
 void DebugStringAdd(ref GedcomImportResult importResult, string str)
 {
     /*if (importResult == null)
      * {
      * importResult = "";
      * }*/
     //importResult += str + "\n";
     importResult.AddString(str);
     trace.TraceInformation(str);
 }
        private bool CheckBomMark(ref GedcomParserProgress progress, ref GedcomImportResult importResult)
        {
            Byte[] fileDataBuffer = fileBuffer.GetBuffer();

            Byte[] UTF_8_BOM    = { 0xEF, 0xBB, 0xBF };
            Byte[] UTF_16BE_BOM = { 0xFE, 0xFF };
            Byte[] UTF_16LE_BOM = { 0xFF, 0xFE };

            bool match;

            match = true;
            for (int i = 0; match && (i < UTF_8_BOM.Length); i++)
            {
                if (UTF_8_BOM[i] != fileDataBuffer[i])
                {
                    match = false;
                }
            }
            if (match)
            {
                importResult.AddString("BOM says UTF-8!");
                //trace.TraceInformation();
                SetCharacterSet(GedcomFileCharacterSet.Utf8);
                progress.position = UTF_8_BOM.Length;
                return(true);
            }
            match = true;
            for (int i = 0; match && (i < UTF_16BE_BOM.Length); i++)
            {
                if (UTF_16BE_BOM[i] != fileDataBuffer[i])
                {
                    match = false;
                }
            }
            if (match)
            {
                importResult.AddString("BOM says UTF-8!");
                //trace.TraceInformation("BOM says UTF-16-BE!");
                SetCharacterSet(GedcomFileCharacterSet.Utf16BE);
                progress.position = UTF_16BE_BOM.Length;
                return(true);
            }

            match = true;
            for (int i = 0; match && (i < UTF_16LE_BOM.Length); i++)
            {
                if (UTF_16LE_BOM[i] != fileDataBuffer[i])
                {
                    match = false;
                }
            }
            if (match)
            {
                importResult.AddString("BOM says UTF-16-LE!");
                //trace.TraceInformation("BOM says UTF-16-LE!");
                SetCharacterSet(GedcomFileCharacterSet.Utf16LE);
                progress.position = UTF_16LE_BOM.Length;
                return(true);
            }
            importResult.AddString("BOM not found!");

            return(false);
        }