Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / November 2004

Tip: Looking for answers? Try searching our database.

Unicode and newline characters in XML text sond via Web Service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Krzysztof Fink-Finowicki - 31 Oct 2004 12:48 GMT
Hi,

I fill-in text in TEXTAREA tag on HTML page, then send its content via content of XML element parameter sent through WebService function from JavaScript.

On client side, I can read my text in debugger as:

<Text>?Omr?de?
?hj?lp?</Text>

(with literal newline).

On server side, transferred content of XML tag looks as:

<Text>???Omr??de???
???hj??lp???</Text>

(the newline character is displayed in Notepad as single square).

Server side text is then stored to database.

This effect causes:
- differences between client and server texts regarding newline characters;
- loss of national characters.

How and where should I set encoding parameters for Web Service transmission to overcome these problems ?

Please help.

    Krzysztof
Dan Rogers - 15 Nov 2004 23:29 GMT
Hi Crzysztof,

The issue would seem to be related to XML encoding and decoding.  From your
HTML page, you are starting with (by default) an ASCII text encoding.  Then
if you are using a properly implemented DOM, and again default encodings,
the client side XML would be encoded as UTF-8.

On the server side, the XML would need to be decoded as UTF-8 for the
newlines to be properly decoded (or if you have specified and propertly
encoded in another encoding, whatever encoding you have chosen).

Using Notepad to show the text can be introducing uncertainty into your
observations.  Notepad can decode UTF-8 if BOM marks are in the file.  If
BOM is not present, notepad will decode as unicode, causing some errors
being introduced that may not be there.

In general, ignoring text printouts, strings and debuggers, if your stack,
end to end, is standard compliant and your programs properly account for
the encoding variations between HTML and XML, and your service
implementation doesn't try to treat the XML received as a string, your
database will probably get the data as decoded from the XML.  This may not
be the result you expect - but there will be the most accurate preservation
of the received data.

For newlines, there is the issue of platform to consider as well.  Notepad,
for instance, displays a newline character (a single character) as a black
square, and the expected carriage return operation doesn't occur.  On most
windows file editors, CR-NL is the expected conversion of a newline
character.  A well implemented XML layer, such as the MS-XML DOM, can help
you, as will the ASP.NET (.NET framework) XML serializer when conversion is
done from XML to string.

If you are going cross platform, the best answer is to use the XML layer in
the middle that is appropriate for each platform, and allow that to
properly deal withe newline characters instead of directly displaying them
in text editors.

I hope this helps,

Dan Rogers
Microsoft Corporation
--------------------
>From:     Krzysztof Fink-Finowicki via .NET 247 <anonymous@dotnet247.com>
>X-Newsreader: AspNNTP 1.50 (Matthew Reynolds Consulting)
[quoted text clipped - 8 lines]
>Lines: 1        
>Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12
phx.gbl
>Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.aspnet.webservices:26321
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
>
>Hi,
>
>I fill-in text in TEXTAREA tag on HTML page, then send its content via content of XML element parameter sent through WebService function from
JavaScript.

>On client side, I can read my text in debugger as:
>
[quoted text clipped - 28 lines]
>
><Id>sAs4+gU7UEemOxcQMxH2qw==</Id

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.