Interpret numeric values as being hexadecimal values if they contain hex digits a-f
Modified: trunk/irc/TechBot/TechBot.Library/NumberParser.cs

Modified: trunk/irc/TechBot/TechBot.Library/NumberParser.cs
--- trunk/irc/TechBot/TechBot.Library/NumberParser.cs	2005-02-16 23:08:04 UTC (rev 13611)
+++ trunk/irc/TechBot/TechBot.Library/NumberParser.cs	2005-02-16 23:17:17 UTC (rev 13612)
@@ -7,13 +7,43 @@
 	{
 		public bool Error = false;
 		
+		private const string SpecialHexCharacters = "ABCDEF";
+
+		private bool IsSpecialHexCharacter(char ch)
+		{
+			foreach (char specialChar in SpecialHexCharacters)
+			{
+				if (ch.ToString().ToUpper() == specialChar.ToString())
+					return true;
+			}
+			return false;
+		}
+
+		private bool HasSpecialHexCharacters(string s)
+		{
+			foreach (char ch in s)
+			{
+				if (IsSpecialHexCharacter(ch))
+					return true;
+			}
+			return false;
+		}
+		
 		public long Parse(string s)
 		{
 			try
 			{
 				Error = false;
+				bool useHex = false;
 				if (s.StartsWith("0x"))
-					return Int64.Parse(s.Substring(2),
+				{
+					s = s.Substring(2);
+					useHex = true;
+				}
+				if (HasSpecialHexCharacters(s))
+					useHex = true;
+				if (useHex)
+					return Int64.Parse(s,
 					                   NumberStyles.HexNumber);
 				else
 					return Int64.Parse(s);