473,394 Members | 1,865 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

\r\n problem

Hi there,

I'm making a call to "DataSet.WriteXml(string fileName)" and the call is
converting all occurrences of "\r\n" to "\n" in the resulting file (for
string columns in each of my tables). Is there a way to write the "\r\n"
combination as-is or otherwise convert the "\n" back to "\r\n" automatically
when I later read it back in via "DataSet.ReadXml()"? Thanks very much.
Jan 7 '08 #1
4 1967
Hi John,

I am unable to reproduse your issue. All my attempts at WriteXml correctly
produces the byte values 13 + 10 (\r\n) both between rows as well as string
values containing line breaks.

How do you know they are converted to \n? Are you sure they aren't \n to
begin with? Some controls are able to do linebreaks with just \n effectively
hiding the lack or \r.

--
Happy Coding!
Morten Wennevik [C# MVP]
"John B." wrote:
Hi there,

I'm making a call to "DataSet.WriteXml(string fileName)" and the call is
converting all occurrences of "\r\n" to "\n" in the resulting file (for
string columns in each of my tables). Is there a way to write the "\r\n"
combination as-is or otherwise convert the "\n" back to "\r\n" automatically
when I later read it back in via "DataSet.ReadXml()"? Thanks very much.
Jan 7 '08 #2
Hi John,
>
I am unable to reproduse your issue. All my attempts at WriteXml
correctly
produces the byte values 13 + 10 (\r\n) both between rows as well as
string
values containing line breaks.

How do you know they are converted to \n? Are you sure they aren't \n to
begin with? Some controls are able to do linebreaks with just \n
effectively
hiding the lack or \r.
Thanks for the feedback. I just tried creating a new project and lo and
behold I get the same (expected) results as you. In my own app however the
problem persists which I've verified by inspecting my strings in the
debugger (just before "WriteXml()") and then examining the resulting file
afterwards (with a hex editor). This conversion is actually backwards in any
case. Normally a LF is converted to a CR/LF on output and back to a LF on
input (when conducting "text" vs "binary" mode processing in general). Note
that I also found at least one other posting where someone reported the same
problem but they got no response. I'll just have to look deeper now that I
see the problem isn't there in a new app. Perhaps some property was turned
on that affects this though not by me AFAIK. I'll let you know the outcome.
Thanks again.
Jan 7 '08 #3
Thanks for the feedback. I just tried creating a new project and lo and
behold I get the same (expected) results as you. In my own app however the
problem persists which I've verified by inspecting my strings in the
debugger (just before "WriteXml()") and then examining the resulting file
afterwards (with a hex editor). This conversion is actually backwards in
any case. Normally a LF is converted to a CR/LF on output and back to a LF
on input (when conducting "text" vs "binary" mode processing in general).
Note that I also found at least one other posting where someone reported
the same problem but they got no response. I'll just have to look deeper
now that I see the problem isn't there in a new app. Perhaps some property
was turned on that affects this though not by me AFAIK. I'll let you know
the outcome. Thanks again.
Ok, I couldn't find any problem so I reboot my machine (in desperation) and
now it's working. Go figure. I have a new (related) problem however. When I
read it back in using the "ReadXml(XmlReader xmlReader)" overload, it's
converting my "\r\n" to a "\n". IOW, it's performing the standard text mode
conversion mentioned in my last post but it doesn't do this if I simply
invoke "ReadXml(string fileName" instead (though I need the former overload
for its validation capabilities). I've been playing with the "XmlReader"
properties but can't find a way to eliminate this so far. Do you know how to
do this offhand? Thanks again.
Jan 7 '08 #4
I have the same problem. I'm calling a web service that returns a sting.
The string contains \r\n. This value is converted to \n in the client
application. So I think this is a serialization problem.

Jan 17 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

117
by: Peter Olcott | last post by:
www.halting-problem.com
28
by: Jon Davis | last post by:
If I have a class with a virtual method, and a child class that overrides the virtual method, and then I create an instance of the child class AS A base class... BaseClass bc = new ChildClass();...
6
by: Ammar | last post by:
Dear All, I'm facing a small problem. I have a portal web site, that contains articles, for each article, the end user can send a comment about the article. The problem is: I the comment length...
7
by: beadman | last post by:
Hello I am trying to use autonumber on an invoice with the prexif "CRW", so the Invoice ID will be CRW00001, CRW00002..and so on. I have put a Format of "CRW"00000 in the table design for the...
6
by: davidson1 | last post by:
Hi, If I type @ symbol in the unix , the cursor is moving to the place where I started typing, what I can do to resolve this problem.Thanks in Advance.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.