+2005-12-09 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XmlInputStream.cs :
+ Added Encoding property on NonBlockingStreamReader
+ * XmlTextReader.cs :
+ set Encoding property when it proceeds to xml declaration.
+
2005-12-09 Atsushi Enomoto <atsushi@ximian.com>
* XmlReader.cs : ReadToDescendant() should work when its ReadState is
pos = 0;
}
+ public Encoding Encoding {
+ get { return encoding; }
+ }
+
public override void Close ()
{
Dispose (true);
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
+2005-12-09 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XmlTextReaderTests.cs : added test for Encoding property.
+
2005-12-09 Atsushi Enomoto <atsushi@ximian.com>
* XmlReaderCommonTests.cs : added tests for ReadToDescendant() and
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);
+ }
}
}