Russian Characters and ASP.Net

  • Thread starter Ross Noe via .NET 247
  • Start date
D

Derek Harmon

Ross Noe via .NET 247 said:
I created an XML file using ASP that has Russian characters. For some
reason ASP.Net doesn't read the Russian characters properly. Is .net
capable of reading Russian characters from an XML file created with ASP?

Almost certainly so, this is probably a difference in encoding between the
ASP application that generated the XML document containing Russian
characters and the encoding used by ASP.NET to read them. Assuming
the ASP and ASP.NET applications are on the same web server, then
they had access to the same code pages, therefore ASP.NET can read
the document once it is reading it using the correct Encoding. You just
need to tell it which one.

The XML document should be created with an XMLDecl that contains
an encoding pseudo-attribute. The correct encoding should be specified
there by the ASP application when it produces the XML file. If you had
previously used a similar ASP application to consume the XML file in the
past, it's possible you may not have noticed the XML file was missing this
necessary encoding declaration because both of your applications had a
tacit agreement as to the encoding going on. The encoding declaration is
important for different platforms to successfully interoperate with each
other.

In ASP.NET, try loading the XML file through a StreamReader and make
sure you create the StreamReader by passing it an Encoding (if you're not
sure which ones to use, start with the obvious Unicode (UTF-16) one and
if that doesn't work then proceed from there to GetEncoding( ) for various
Russian code pages, see the documentation for the System.Text.Encoding
class for more info on getting the encoding associated with a code page).

I suggest StreamReader because you need to take control of precisely what
encoding the XmlTextReader that it'll be wrapped by (if not by you, then by
the Load( ) method of XmlDocument) uses to read it. You don't have this
degree of control if you use one of the short-cut overloads that takes a file
name.


Derek Harmon
 
K

Kevin Spencer

Russian characters have always been a problem. I remember the first Russian
characters I encountered - Boris Badenov and Natasha Fatale, on the Ricky
and Bullwinkle cartoons. Boy, they were always causing trouble! Don't forget
Nikita Kruschev, who once pounded his shoe on a table at the U.N. to make a
point. And of course today we have Vladimir Putin, who, while certainly
lacking the outward hostility of his precursors, still manages to throw a
wrench in the works now and then.

Wish I could tell you what to do about them. Hopefully, at least I've
managed to relieve some of your tension.

--
;-),

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

(Type your message here)

--------------------------------
From: Ross Noe
I created an XML file using ASP that has Russian characters. For some reason
ASP.Net doesn't read the Russian characters properly. Is .net capable of
reading Russian characters from an XML file created with ASP? The
application that the users use to update the XML file is still written in
ASP and not in ASP.Net. Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top