473,698 Members | 2,198 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error opening xml file with ANSI encoding

I'm doig a test using XP English with LocalSettings set to Russian.
When trying to open an XML file with ANSI encoding, I get errors. When
I change the encoding to UTF8, I can read the file successfully.

I'm wondering why this happens. Any help is appreciated.

thanks
Sunit

Nov 17 '05 #1
3 3034
sjoshi <sj****@ingr.co m> wrote:
I'm doig a test using XP English with LocalSettings set to Russian.
When trying to open an XML file with ANSI encoding, I get errors.
What errors, exactly?
When I change the encoding to UTF8, I can read the file successfully.

I'm wondering why this happens. Any help is appreciated.


Does the encoding of the file on disk match the encoding of the file as
specified within the file itself?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
There is no encoding specified in the declaration and the file was
saved on a XP english original machine with LocalSettings are set to
Russian. If I open the file in VSNet and then do a SaveAs with UTF-8
encoding, it works fine.

That brings me to another question, Is there a way to find the ecoding
of an XML file in .NET ?

thanks
Sunit

Nov 17 '05 #3
sjoshi <sj****@ingr.co m> wrote:
There is no encoding specified in the declaration
That's the problem then. If no encoding is specified in the
declaration, it's assumed to be UTF-8, according to the XML
specification.
and the file was
saved on a XP english original machine with LocalSettings are set to
Russian. If I open the file in VSNet and then do a SaveAs with UTF-8
encoding, it works fine.

That brings me to another question, Is there a way to find the ecoding
of an XML file in .NET ?


Not sure - if you got the XmlDeclaration somehow, you could ask that -
but I don't know whether the encoding is filled in automatically if
it's not present.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #4

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

Similar topics

3
3381
by: aa | last post by:
Is it OK to include an ANSI file into a UTF-8 file?
9
29228
by: wordsender | last post by:
Hey guys, I can't figure this one out, why is this simple script giving me problems? logfile=file(r'test.txt','w') logfile.write('datetime') test=logfile.readlines() When I run it I get the error message:
6
2793
by: dbaldi | last post by:
(this is follow-on message to one posted yesterday) I'm trying to reproduce the capabilities in both Notepad and Excel, whereby a Unicode text file with Unicode characters can be converted to ANSI, while still preserving the unicode characters within. Specifically, I'm using the unicode character &x2022, which is a largish bullet. I've tried this:
6
4748
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much appreciated. Thanks in advance
7
7754
by: Drew Berkemeyer | last post by:
Hello, I'm using the following code to read a text file in VB.NET. Dim sr As StreamReader = File.OpenText(strFilePath) Dim input As String = sr.ReadLine() While Not input Is Nothing strReturn += input + vbCrLf input = sr.Read
2
8168
by: Nikolay Petrov | last post by:
How to read ANSI text. The sream reader reads only UTF-8
1
1790
by: Jeff User | last post by:
Hi all C#, .net1.1, plain old aspx page with nothing on it. The aspx page is named ViewComments.aspx I read a clob column from an Oracle db. then I send it to the Response out like this: //Where the clob data is found in the DataSet ds
7
92500
by: firepol | last post by:
Hello there, I am dealing with files encoded in UTF8 and I can't find a way to convert them into ANSI. I've already searched in google for this since a while, and I'm not achieving the result I want to achieve if I use the code I've found on the web, which is the following: Example of test.txt (save it as UTF8): "éàèüöä" string filePath = "c:\\test.txt"; StreamReader fileStream = new StreamReader(filePath); string fileContent =...
0
2353
by: rajana | last post by:
Dear All, We have Ansi file with german characters (Ä / Ø) , We are using Streamreader to read the contents of the file. But Readline() not able to read the German characters. We tried all possibilities of calling the streamreader, but nothing worked. Dim sr As StreamReader = New StreamReader(Filename, System.Text.Encoding.Default, True) Dim sr As StreamReader = New StreamReader(Filename, _System.Text.Encoding.ASCII, False, 512)
0
8676
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
8608
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
9164
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...
0
9029
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8870
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7734
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
5860
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2006
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.