473,785 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

/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 10532
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 SoapMessageStag e.AfterSerializ e event)
....

protected void CopyFromToEx(St ream from, Stream to) {
TextReader reader = new StreamReader(fr om);
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.En coding.UTF8.Get Bytes(l_b)[0] == 13 )
writer.Write("& #x000d;");
else if (System.Text.En coding.UTF8.Get Bytes(l_b)[0] == 10)
writer.Write("& #x000a;");
else
writer.Write(l_ b);

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

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

"Enrico Sabbadin" <xwrote in message
news:uq******** ******@TK2MSFTN GP02.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.Enc oding.UTF8.GetB ytes 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 SoapMessageStag e.AfterSerializ e event)
....

protected void CopyFromToEx(St ream from, Stream to) {
TextReader reader = new StreamReader(fr om);
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.En coding.UTF8.Get Bytes(l_b)[0] == 13 )
writer.Write("
");
else if (System.Text.En coding.UTF8.Get Bytes(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******** ******@TK2MSFTN GP02.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
31372
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? Any help will be greatly appreciate. Regards,
1
2216
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. (Hex 0d0a). My filter adds the header in the correct format, including the entire encrypted cookie value (set-cookie: mycookie=theEncryptedValue;path=/;). However, when the isapi filter finishes running, the browser only gets part of the...
1
850
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 part of a string that is transferred to a web service method. The XML 1.1 standard is supposed to address this problem, however, we are not aware of any plans of ASMX and serializers to implement this standard in the near future.
2
38767
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
18775
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 in a text field I only see quads. Tia Torsten
0
1115
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 collection ok except that the last value has a \r\n padded, which is not expected. Is this normal behaviour? My workaround is to add another pair/value which serves as dummy and let the \r\n get padded to it.
0
1825
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 to correctly encode them. I am trying to return XML strings that were generated by calling DataTable.WriteXml() from my web service, and then using DataTable.ReadXml to deserialize the data. The problem is that some of the data in the...
2
900
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 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...
8
19796
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 already, code is in a loop.., //body += "%0A" + txtMessage.Text.Substring(CurPos, 1); //body += "<CF><LF>" + " " +txtMessage.Text.Substring(CurPos, 1); //body += "'CRLF:\r\nPost CRLF'" + txtMessage.Text.Substring(CurPos, 1); //body += "<br>" +...
0
1789
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 Microsoft Outlook. Outlook displays a message like "Extra line breaks in this message were removed". I've had the same problem for a long time, and found a solution quite by accident. Ensuring that each line ends with a period (.) prior to the...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9481
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10336
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10095
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8978
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.