Author: atsushi
Date: 2005-12-09 11:37:22 -0500 (Fri, 09 Dec 2005)
New Revision: 54166
Modified:
trunk/mcs/class/System.XML/System.Xml/ChangeLog
trunk/mcs/class/System.XML/System.Xml/XmlInputStream.cs
trunk/mcs/class/System.XML/System.Xml/XmlTextReader.cs
trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog
trunk/mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs
Log:
2005-12-09 Atsushi Enomoto <[EMAIL PROTECTED]>
* XmlInputStream.cs :
Added Encoding property on NonBlockingStreamReader
* XmlTextReader.cs :
set Encoding property when it proceeds to xml declaration.
* XmlTextReaderTests.cs : added test for Encoding property.
Modified: trunk/mcs/class/System.XML/System.Xml/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/ChangeLog 2005-12-09 16:03:16 UTC
(rev 54165)
+++ trunk/mcs/class/System.XML/System.Xml/ChangeLog 2005-12-09 16:37:22 UTC
(rev 54166)
@@ -1,5 +1,12 @@
2005-12-09 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * XmlInputStream.cs :
+ Added Encoding property on NonBlockingStreamReader
+ * XmlTextReader.cs :
+ set Encoding property when it proceeds to xml declaration.
+
+2005-12-09 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* XmlReader.cs : ReadToDescendant() should work when its ReadState is
Initial.
Modified: trunk/mcs/class/System.XML/System.Xml/XmlInputStream.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlInputStream.cs 2005-12-09
16:03:16 UTC (rev 54165)
+++ trunk/mcs/class/System.XML/System.Xml/XmlInputStream.cs 2005-12-09
16:37:22 UTC (rev 54166)
@@ -122,6 +122,10 @@
pos = 0;
}
+ public Encoding Encoding {
+ get { return encoding; }
+ }
+
public override void Close ()
{
Dispose (true);
Modified: trunk/mcs/class/System.XML/System.Xml/XmlTextReader.cs
===================================================================
--- trunk/mcs/class/System.XML/System.Xml/XmlTextReader.cs 2005-12-09
16:03:16 UTC (rev 54165)
+++ trunk/mcs/class/System.XML/System.Xml/XmlTextReader.cs 2005-12-09
16:37:22 UTC (rev 54166)
@@ -1980,6 +1980,16 @@
if (message != null)
throw NotWFError (message);
+ string encoding = GetAttribute ("encoding");
+ if (encoding != null) {
+ if (!XmlChar.IsValidIANAEncoding (encoding))
+ throw new XmlException (String.Format
("Encoding name must be a valid IANA name: {0}", encoding));
+ if (reader is XmlStreamReader)
+ parserContext.Encoding =
((XmlStreamReader) reader).Encoding;
+ else
+ parserContext.Encoding =
Encoding.Unicode;
+ }
+
SetProperties (
XmlNodeType.XmlDeclaration, // nodeType
"xml", // name
Modified: trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog 2005-12-09
16:03:16 UTC (rev 54165)
+++ trunk/mcs/class/System.XML/Test/System.Xml/ChangeLog 2005-12-09
16:37:22 UTC (rev 54166)
@@ -1,5 +1,9 @@
2005-12-09 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * XmlTextReaderTests.cs : added test for Encoding property.
+
+2005-12-09 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* XmlReaderCommonTests.cs : added tests for ReadToDescendant() and
ReadToFollowing().
Modified: trunk/mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs
===================================================================
--- trunk/mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs
2005-12-09 16:03:16 UTC (rev 54165)
+++ trunk/mcs/class/System.XML/Test/System.Xml/XmlTextReaderTests.cs
2005-12-09 16:37:22 UTC (rev 54166)
@@ -1153,5 +1153,15 @@
XmlNodeType.Document, null);
xtr.Read ();
}
+
+ [Test]
+ public void EncodingProperty ()
+ {
+ string xml = "<?xml version=\"1.0\"
encoding=\"iso-8859-1\"?>\n<root>\n<node>\nvalue\n</node>\n</root>";
+ XmlTextReader xr = new XmlTextReader (xml,
XmlNodeType.Document, null);
+ AssertNull ("#1", xr.Encoding);
+ xr.Read ();
+ AssertEquals ("#2", Encoding.Unicode, xr.Encoding);
+ }
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches