diff --git a/Assignment 1/Program.cs b/Assignment 1/Program.cs
index d0eff38..297d21b 100644
--- a/Assignment 1/Program.cs
+++ b/Assignment 1/Program.cs
@@ -716,6 +716,30 @@ namespace Assignment_1
return c;
}
+ ///
+ /// Reads the previous char
+ ///
+ ///
+ ///
+ static char PreviousChar(Stream s)
+ {
+ Stack charBytes = new Stack(4);
+ for (int i = 0; i < 4; i++)
+ {
+ if (s.Position == 0)
+ {
+ break;
+ }
+ s.Position--;
+ byte read = (byte)s.ReadByte();
+ charBytes.Push(read);
+ // No longer an UTF-8 extension, last byte is the final
+ if (read >> 6 != 2) break;
+ }
+ string converted = Encoding.UTF8.GetString(charBytes.ToArray());
+ return converted[0];
+ }
+
///
/// Skips whitespace characters
///