473,323 Members | 1,551 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,323 software developers and data experts.

/r/n (13-10) (carriage return - line feed) in web services

Hi,
A few days go I fiund iut that the xmlserializer strips away /r/n out during
deserialization (and just leave /n)
... I found out that you can resolve this problem using the deserialize
overlaod that takes an xmltextreader instead of a stream ..

However when it's time to Web Services you have no such a control over the
deserialization phase AND I found out that WS strips out /r/n (an leave /n)
... I understand there are some XMl specs related to this .. however . what
one should do to have a /r/n sequence into a string property of his own
custom object ?

I saw that writing /r/n as unicode numbers does work .. however this implies
writing some custom soap extension / http module to replace 0d,0a sequences
to their unicode equivalence ( ..and .. btw .. how do I avoid to mix up
binary data eventually transmitted that contains this sequence ?) .. are
there better way to solve this ?

Any suggestion is appreciated.
thank a lot
Enrico Sabbadin

Nov 13 '06 #1
2 10505
I've done a soap extension that replace /r/n with 
 and 

it looks like working .. if someone is interested

(it hooks into client and server SoapMessageStage.AfterSerialize event)
....

protected void CopyFromToEx(Stream from, Stream to) {
TextReader reader = new StreamReader(from);
TextWriter writer = new StreamWriter(to);
char[] l_b = new char[1];
int i = 0;
while (reader.Read(l_b,0,1)!=0) {
if (System.Text.Encoding.UTF8.GetBytes(l_b)[0] == 13 )
writer.Write("
");
else if (System.Text.Encoding.UTF8.GetBytes(l_b)[0] == 10)
writer.Write("
");
else
writer.Write(l_b);

i++;
}
writer.Flush();
}

........
is there a better way ?

"Enrico Sabbadin" <xwrote in message
news:uq**************@TK2MSFTNGP02.phx.gbl...
Hi,
A few days go I fiund iut that the xmlserializer strips away /r/n out
during deserialization (and just leave /n)
.. I found out that you can resolve this problem using the deserialize
overlaod that takes an xmltextreader instead of a stream ..

However when it's time to Web Services you have no such a control over the
deserialization phase AND I found out that WS strips out /r/n (an leave
/n) .. I understand there are some XMl specs related to this .. however .
what one should do to have a /r/n sequence into a string property of his
own custom object ?

I saw that writing /r/n as unicode numbers does work .. however this
implies writing some custom soap extension / http module to replace 0d,0a
sequences to their unicode equivalence ( ..and .. btw .. how do I avoid to
mix up binary data eventually transmitted that contains this sequence ?)
.. are there better way to solve this ?

Any suggestion is appreciated.
thank a lot
Enrico Sabbadin
Nov 13 '06 #2
Hi Enrico,

This will work. I just wanted to add a note that you don't have to use the
System.Text.Encoding.UTF8.GetBytes because the \r and \n characters have the
same integer value in UTF-8 and UTF-16. You can directly test it, such as:

if (l_b[0] == 13 )

Also the \n character does not have to be escaped since it is not going to
get stripped out by the XML normalization (unless it is in an attribute
value).

Hope that helps.

Thanks,
-Helena Kotas

"Enrico Sabbadin" wrote:
I've done a soap extension that replace /r/n with
and
it looks like working .. if someone is interested

(it hooks into client and server SoapMessageStage.AfterSerialize event)
....

protected void CopyFromToEx(Stream from, Stream to) {
TextReader reader = new StreamReader(from);
TextWriter writer = new StreamWriter(to);
char[] l_b = new char[1];
int i = 0;
while (reader.Read(l_b,0,1)!=0) {
if (System.Text.Encoding.UTF8.GetBytes(l_b)[0] == 13 )
writer.Write("
");
else if (System.Text.Encoding.UTF8.GetBytes(l_b)[0] == 10)
writer.Write("
");
else
writer.Write(l_b);

i++;
}
writer.Flush();
}

........
is there a better way ?

"Enrico Sabbadin" <xwrote in message
news:uq**************@TK2MSFTNGP02.phx.gbl...
Hi,
A few days go I fiund iut that the xmlserializer strips away /r/n out
during deserialization (and just leave /n)
.. I found out that you can resolve this problem using the deserialize
overlaod that takes an xmltextreader instead of a stream ..

However when it's time to Web Services you have no such a control over the
deserialization phase AND I found out that WS strips out /r/n (an leave
/n) .. I understand there are some XMl specs related to this .. however .
what one should do to have a /r/n sequence into a string property of his
own custom object ?

I saw that writing /r/n as unicode numbers does work .. however this
implies writing some custom soap extension / http module to replace 0d,0a
sequences to their unicode equivalence ( ..and .. btw .. how do I avoid to
mix up binary data eventually transmitted that contains this sequence ?)
.. are there better way to solve this ?

Any suggestion is appreciated.
thank a lot
Enrico Sabbadin

Nov 15 '06 #3

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

Similar topics

6
by: | last post by:
Hi, I want to send an Email using ASP (I know how to to this) The body of the Email contains several variabels How do I concat string values and separate them by carriage returns/ Line feeds? ...
1
by: Neil S. | last post by:
I am writing an ISAPI filter which is using CAPICOM to encrypt and decrypt cookie information. I've found that the encryption string being returned by CAPICOM a has carriage control and line feed....
1
by: wschaub | last post by:
Is there any way of forcing an ASMX web service not to translate a carriage return – line feed (\r\n) with a (\n\n), in other words the carriage return \r is replaced with a \n if contained as...
2
by: John Dalberg | last post by:
Hi What's the regex to remove the carriage return/line field from a string? These can occur multiple times in the string as in xxx\r\n\r\n. -- John Dalberg
2
by: Torsten Zachert | last post by:
I would like to insert some text with embedded carriage return/line feed into a MS Access text field with OleDb and C# ADO.NET. I tried to use "\n" in combination with "\r". If I display the input...
0
by: John Dalberg | last post by:
I noticed that when I add key/value pairs to a NameValueCollection variable and send this collection through a POST using WebClient.UploadValues method, the recepient process receives the...
0
by: J.Marsch | last post by:
I am having a problem in which ASP.Net web services are corrupting my data. I know that my problem is related to the standard way of encoding carriage return linefeeds, so I need to figure out how...
2
by: Enrico Sabbadin | last post by:
Hi, A few days go I fiund iut that the xmlserializer strips away /r/n out during deserialization (and just leave /n) ... I found out that you can resolve this problem using the deserialize...
8
by: kcovert | last post by:
using System.Net.Mail; I've been unable to get a carriage return/line feed into the body of my Outlook message. Have look all over the web for a soltion with no luck. Here's what I have tried...
0
by: Hayduke | last post by:
I've observed various posts here and elsewhere concerning CRLFs getting stripped out of programatically generated emails. This behavior is evident when the email is viewed using various versions of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.