Encoding ISO-8859-1

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to create a System.Text.Encoding for ISO-8859-1 in a similar
fashion to this line that creates an Encoding for UTF8:

private Encoding encoding = Encoding.UTF8;

Then, I want to test that ISO-8859-1 Encoding like this line tests UTF8:

bool result = encoding is Encoding.UTF8;

Does anyone have any ideas?

Thanks,
 
Encoding.UTF8 is only a shortcut to creating a commonly used encoder. How
about trying something like Encoder.GetEncoding("iso-8859-1")?
 
In addition, to check if the encoding is iso-8859-1, you can compare it
BodyName property to "iso-8859-1".
 
Peter Rilling said:
Encoding.UTF8 is only a shortcut to creating a commonly used encoder. How
about trying something like Encoder.GetEncoding("iso-8859-1")?

Or Encoding.GetEncoding (28591) (which is the Windows code page for
ISO-8859-1).
 
Hi Dale,

Thanks for posting!

For the current issue, there are many ways to approach this comparison. The
Encoding.GetEncoding is the easy way to implement. Just for your reference:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemtextencodingclassgetencodingtopic.asp

By the way, the Encoder class has no method such as GetEncoding. I think
Peter just make a writing mistake.

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
 
That definitely solves the rest of my dilemma, how to identify what kind of
Encoder I have. So I just have to switch gears a little instead of comparing
objects, I will compare the name of the object.

Thanks for your help!
 
Other than agreeing with Yuan about the minor error in that you meant
Encoding.GetEncoding rather than Encoder.GetEncoding, your response did get
me the right Encoder.

Thanks for your help,
--
Dale Preston
MCAD C#
MCSE, MCDBA


Peter Rilling said:
Encoding.UTF8 is only a shortcut to creating a commonly used encoder. How
about trying something like Encoder.GetEncoding("iso-8859-1")?
 
Thanks Jon. That's a good point. And numbers are much easier to type
exactly correct than strings.
--
Dale Preston
MCAD C#
MCSE, MCDBA
 
Thanks for responding, Yuan. With all the responses put together I am
beginning to get enough of an understanding of the whole Encoding framework.

Too bad that the .Net framework doesn't support Unicode BigEndian and
ISO-8859-1 as natively as it does ASCII and UTF-8/16 (i.e. supporting them as
properties of the Encoding class as are ASCIIEncoding and UTF8Encoding.) It
would go a long way towards improving interoperability between .Net and other
environments.

In any case, my dilemma is solved and I appreciate your help!

Thanks,
 
Thus wrote Dale,
Thanks for responding, Yuan. With all the responses put together I am
beginning to get enough of an understanding of the whole Encoding
framework.

Too bad that the .Net framework doesn't support Unicode BigEndian and
ISO-8859-1 as natively as it does ASCII and UTF-8/16 (i.e. supporting
them as properties of the Encoding class as are ASCIIEncoding and
UTF8Encoding.) It would go a long way towards improving
interoperability between .Net and other environments.

Encoding.BigEndianUnicode exists, but I strongly agree that there should
be more default instances like

Encoding.IsoLatin1 (28591)
Encoding.IsoLatin9 (28605)
Encoding.WindowsLatin1 (1252)

Cheers,
 
Dale said:
Thanks for responding, Yuan. With all the responses put together I am
beginning to get enough of an understanding of the whole Encoding framework.

Too bad that the .Net framework doesn't support Unicode BigEndian and
ISO-8859-1 as natively as it does ASCII and UTF-8/16 (i.e. supporting them as
properties of the Encoding class as are ASCIIEncoding and UTF8Encoding.) It
would go a long way towards improving interoperability between .Net and other
environments.

It does support Unicode big endian in the same way - see
Encoding.BigEndianUnicode.
 
Hi Dale,

Thanks for your reply!

As other commuicators mentioned, the .NET supports Unicode big endian. I'm
glad to hear your issue is resolved!

Regards,

Yuan Ren [MSFT]
Microsoft Online Support
======================================================
PLEASE NOTE the newsgroup SECURE CODE and PASSWORD were
updated on February 14, 2006. Please complete a re-registration process
by entering the secure code mmpng06 when prompted. Once you have
entered the secure code mmpng06, you will be able to update your profile
and access the partner newsgroups.
======================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from this issue.
======================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
======================================================
 

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

Back
Top