private static string ReadToEndOfSection(TextReader reader, TextWriter writer, string lastProperty, int currentCount, IUcdCharacter ucdCharacter)
{
string line;
while ((line = reader.ReadLine()) != null)
{
// if there is a bidi class value to read
if (HasBidiData(line))
{
// increments the current count of codepoints found so far.
IncrementCount(ref currentCount, line);
// read the bidi value from the line
var currentProperty = GetProperty(line);
// if it isn't in the current section we are done with section.
if (!ucdCharacter.SameRegion(currentProperty, lastProperty))
break;
}
// if its a comment, find the total count comment and replace it with the current count.
else if (line.ToLowerInvariant().IndexOf("total code points") != -1)
{
line = "# Total code points: " + currentCount;
currentCount = 0;
}
// Write through all lines except the first line of the next section
writer.WriteLine(line);
}
// Return the last line that we read
// This is the first line of the next section, so someone will probably want to parse it.
return line;
}