2007-08-04 Jb Evain <jbevain@novell.com>
authorJb Evain <jbevain@gmail.com>
Thu, 9 Aug 2007 12:57:04 +0000 (12:57 -0000)
committerJb Evain <jbevain@gmail.com>
Thu, 9 Aug 2007 12:57:04 +0000 (12:57 -0000)
* XmlInputStream.cs: there's no ASCII encoding in 2.1.

svn path=/trunk/mcs/; revision=83743

mcs/class/System.XML/System.Xml/ChangeLog
mcs/class/System.XML/System.Xml/XmlInputStream.cs

index 4529573096a34cca7bdbb07feb1be5ac88e90882..6659acee01aadced1ad7c970505eb263d3369c65 100644 (file)
@@ -1,3 +1,7 @@
+2007-08-04  Jb Evain  <jbevain@novell.com>
+
+       * XmlInputStream.cs: there's no ASCII encoding in 2.1.
+
 2007-08-09  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XmlReader.cs XmlNodeReader2.cs XmlTextReader.cs XmlTextReader2.cs
index 74df8f7180b0797b3c5a40aaab5c54c5f445d9de..3ef6ef8ef62e9fb2b6a8ce483e5aeafad65fcc62 100644 (file)
@@ -341,6 +341,19 @@ namespace System.Xml
                        Initialize (stream);
                }
 
+               static string GetStringFromBytes (byte [] bytes, int index, int count)
+               {
+#if NET_2_1
+                       char [] chars = new char [count];
+                       for (int i = index; i < count; i++)
+                               chars [i] = (char) bytes [i];
+
+                       return new string (chars);
+#else
+                       return Encoding.ASCII.GetString (bytes, index, count);
+#endif
+               }
+
                private void Initialize (Stream stream)
                {
                        buffer = new byte [64];
@@ -387,7 +400,7 @@ namespace System.Xml
                                break;
                        case '<':
                                // try to get encoding name from XMLDecl.
-                               if (bufLength >= 5 && Encoding.ASCII.GetString (buffer, 1, 4) == "?xml") {
+                               if (bufLength >= 5 && GetStringFromBytes (buffer, 1, 4) == "?xml") {
                                        bufPos += 4;
                                        c = SkipWhitespace ();
 
@@ -405,7 +418,7 @@ namespace System.Xml
 
                                        if (c == 'e') {
                                                int remaining = bufLength - bufPos;
-                                               if (remaining >= 7 && Encoding.ASCII.GetString(buffer, bufPos, 7) == "ncoding") {
+                                               if (remaining >= 7 && GetStringFromBytes (buffer, bufPos, 7) == "ncoding") {
                                                        bufPos += 7;
                                                        c = SkipWhitespace();
                                                        if (c != '=')