xml iso-8859-1 charset

G

Guest

Hi

I'm writing an application for a Pocket PC device in C# which reads some XML filesfrom a web server and display them in a form at the device. The problem is that the XML files are encoded as iso-8859-1 and when I try to read them at the Pocket PC I get a message saying that this encoding is not supported at the Compact Framework. Does somebody know how to parse iso-8859-1 encoded XML files at the Compact Framework

Thanks in advance for giving me a hand ..

Best regards

Johann Granados
 
J

Jon Skeet [C# MVP]

Johann said:
I'm writing an application for a Pocket PC device in C# which reads
some XML filesfrom a web server and display them in a form at the
device. The problem is that the XML files are encoded as iso-8859-1
and when I try to read them at the Pocket PC I get a message saying
that this encoding is not supported at the Compact Framework. Does
somebody know how to parse iso-8859-1 encoded XML files at the Compact
Framework?

Fortunately, that's *really* easy. Easier than for almost any other
encoding.

char[] chars = new char[bytes.Length];
for (int i=0; i < bytes.Length; i++)
{
chars = bytes;
}

Now, if you want to be really stringent, you might want to change it
to:

char[] chars = new char[bytes.Length];
for (int i=0; i < bytes.Length; i++)
{
if (bytes < 128 || bytes > 140)
{
chars = bytes;
}
else
{
chars = '?';
}
}

because I *believe* ISO 8859-1 officially has a "hole" between 128 and
139 inclusive, but many decoders just use Unicode 128-139 to fill the
gap. That also fits in with what the Unicode spec says about ISO
8859-1. Yes, it's all a bit confusing :(
 

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

Top