[Mono-list] XmlTextWriter and \r\n

ville vi64pa@koti.soon.fi
Thu, 16 Jan 2003 21:26:53 +0200


--------------Boundary-00=_TCNTSH9UWBEWWB19J0OG
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: quoted-printable


Hi Atsushi!

Here is what i was talking about in #mono.

example document
<Root>
 <Region>
   <RegionID>1</RegionID>
   <RegionDescription>Eastern
   </RegionDescription>
 </Region>
</Root>

So, there is '\n' end of <RegionsDescription>Eastern
ms .net adds '\r' to the end of Eastern, but mono do not.

I attached patch which fixes this (my tests and it didnt cause any fails =
in=20
System.XML/Tests.)  I know it looks little clumsy, but it worked. You kno=
w=20
this area better so if you can figure out better way to do this....

Ville

--------------Boundary-00=_TCNTSH9UWBEWWB19J0OG
Content-Type: text/x-diff;
  charset="us-ascii";
  name="XmlTextWriter.cs.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="XmlTextWriter.cs.diff"

Index: XmlTextWriter.cs
===================================================================
RCS file: /cvs/public/mcs/class/System.XML/System.Xml/XmlTextWriter.cs,v
retrieving revision 1.27
diff -u -r1.27 XmlTextWriter.cs
--- XmlTextWriter.cs	20 Dec 2002 18:12:54 -0000	1.27
+++ XmlTextWriter.cs	16 Jan 2003 19:03:20 -0000
@@ -607,6 +607,9 @@
 			if (text == null)
 				text = String.Empty;
 
+			if (text.IndexOf ('\n') > -1 && text.IndexOf ('\r') < 0)
+				text = text.Insert (text.IndexOf ('\n'), "\r");
+
 			if (text != String.Empty) 
 			{
 				CheckState ();

--------------Boundary-00=_TCNTSH9UWBEWWB19J0OG--