469,327 Members | 1,226 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

Encoding ISO-8859-1

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,
--
Dale Preston
MCAD C#
MCSE, MCDBA
Feb 16 '06 #1
11 32509
Encoding.UTF8 is only a shortcut to creating a commonly used encoder. How
about trying something like Encoder.GetEncoding("iso-8859-1")?

"Dale" <da******@nospam.nospam> wrote in message
news:AC**********************************@microsof t.com...
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,
--
Dale Preston
MCAD C#
MCSE, MCDBA

Feb 16 '06 #2
In addition, to check if the encoding is iso-8859-1, you can compare it
BodyName property to "iso-8859-1".

Feb 16 '06 #3
Peter Rilling <pe***@nospam.rilling.net> wrote:
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).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 16 '06 #4
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/de...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

Feb 16 '06 #5
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!
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Truong Hong Thi" wrote:
In addition, to check if the encoding is iso-8859-1, you can compare it
BodyName property to "iso-8859-1".

Feb 17 '06 #6
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" wrote:
Encoding.UTF8 is only a shortcut to creating a commonly used encoder. How
about trying something like Encoder.GetEncoding("iso-8859-1")?

"Dale" <da******@nospam.nospam> wrote in message
news:AC**********************************@microsof t.com...
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,
--
Dale Preston
MCAD C#
MCSE, MCDBA


Feb 17 '06 #7
Thanks Jon. That's a good point. And numbers are much easier to type
exactly correct than strings.
--
Dale Preston
MCAD C#
MCSE, MCDBA
"Jon Skeet [C# MVP]" wrote:
Peter Rilling <pe***@nospam.rilling.net> wrote:
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).

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

Feb 17 '06 #8
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,
--
Dale Preston
MCAD C#
MCSE, MCDBA
""Yuan Ren[MSFT]"" wrote:
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/de...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

Feb 17 '06 #9
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,
--
Joerg Jooss
ne********@joergjooss.de
Feb 17 '06 #10
Dale <da******@nospam.nospam> wrote:
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 17 '06 #11
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.
================================================== ====

Feb 20 '06 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Christopher H. Laco | last post: by
9 posts views Thread by PAN | last post: by
5 posts views Thread by DbNetLink | last post: by
9 posts views Thread by Andy | last post: by
9 posts views Thread by Mark | last post: by
4 posts views Thread by Ciuin | last post: by
2 posts views Thread by Steph | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by listenups61195 | last post: by
reply views Thread by Purva khokhar | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.