private bool getNextSfmMarkerAndData(out string sfmMarker, out byte[] sfmData, out byte[] badSfmBytes)
{
badSfmBytes = null;
// exit condition and false return value
if (m_position >= m_FileData.Length)
{
// no data to process
sfmMarker = "";
sfmData = new byte[0];
return false;
}
int startOfMarker = (int)m_position;
int endOfMarker;
// currently positioned at a backslash byte
if (m_FileData[m_position] == m_backSlash)
{
// now start to get the marker
m_position++; // move off the backslash
// The current byte is a backslash, use all bytes until white space
// as part of the marker
byte[] whitespace = new byte[] {0x20, 0x09}; // , 0x0a, 0x0d};
byte[] eol = new byte[] {0x0a, 0x0d};
while (!InArray(whitespace, m_FileData[m_position]) && !InArray(eol, m_FileData[m_position]))
{
// not a whitespace byte, bump the count
m_position++;
if (m_position >= m_FileData.Length)
break;
}
// have hit our first whitespace data or the end of the file
endOfMarker = (int)m_position-1; // save the end position of the marker
// convert the bytes of the sfm marker to the string for it
Converter.MultiToWideError mwError;
sfmMarker = Converter.MultiToWideWithERROR(m_FileData, startOfMarker+1, endOfMarker,
System.Text.Encoding.UTF8, out mwError, out badSfmBytes);
if (m_position < m_FileData.Length)
{
// eat all the white space after the marker
while (InArray(whitespace, m_FileData[m_position]))
{
m_position++;
if (m_position >= m_FileData.Length)
break;
}
}
// m_position now points to the start of the data portion
}
else
sfmMarker = "";
m_FoundLineNumber = m_LineNumber; // save the line for the found marker
sfmData = GetBytesUptoNextSfmMarker();
return true;
}