473,397 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Encoding to ISO-8859-1 problems

Hi,
We are trying to encode to ISO-8859-1, but we have problems doing it using
the encoders in .NET. We get some unknown characters in some culture which
comes out fine if we post (from IE) from a page in ISO-8859-1 to another
page using ISO-8859-1, but cannot take a .NET string or a UTF-8 string,
convert it in ISO-8859-1 and display it with this encoding using the same
content in the string...

Are there anyone that know how IE does it? Is there any correspondance
table, are the any information into the unicode encoding that says "this
character has this style and should convert to another character with this
style" or something like it?

Thanks

ThunderMusic
Feb 1 '07 #1
8 7469
ThunderMusic <No*************************@NoSpAm.comwrote:
We are trying to encode to ISO-8859-1, but we have problems doing it using
the encoders in .NET. We get some unknown characters in some culture which
comes out fine if we post (from IE) from a page in ISO-8859-1 to another
page using ISO-8859-1, but cannot take a .NET string or a UTF-8 string,
convert it in ISO-8859-1 and display it with this encoding using the same
content in the string...

Are there anyone that know how IE does it? Is there any correspondance
table, are the any information into the unicode encoding that says "this
character has this style and should convert to another character with this
style" or something like it?
It's not very clear exactly what's going on. It's quite possible that
when you post in IE, it's not using 8859-1 for the post even if the
pages returned *are* genuinely using 8859-1. It's hard to see how it
would be displayed in that case though.

If a character isn't in 8859-1, you won't be able to represent it in
8859-1.

Do you *have* to use 8859-1 rather than an encoding which can represent
the whole of Unicode (eg UTF-8)?

--
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 1 '07 #2
it's actually because we are sending mails to hotmail, and because our
application is in utf-8 and hotmail uses ISO-8859-1, so if we send a message
encoded using UTF-8, the displayed message comes out plain ugly in
hotmail...

So we must find a way to convert things correctly... to give an exemple of
what should be converted... a character like the oe (o and e tied together)
should be converted to ISO-8859-1 oe (o and e separatly) because the "tied
together" version does not exists in 8859-1...

Anyone knows how to do it seemlessly?

Thanks

ThunderMusic

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
ThunderMusic <No*************************@NoSpAm.comwrote:
>We are trying to encode to ISO-8859-1, but we have problems doing it
using
the encoders in .NET. We get some unknown characters in some culture
which
comes out fine if we post (from IE) from a page in ISO-8859-1 to another
page using ISO-8859-1, but cannot take a .NET string or a UTF-8 string,
convert it in ISO-8859-1 and display it with this encoding using the same
content in the string...

Are there anyone that know how IE does it? Is there any correspondance
table, are the any information into the unicode encoding that says "this
character has this style and should convert to another character with
this
style" or something like it?

It's not very clear exactly what's going on. It's quite possible that
when you post in IE, it's not using 8859-1 for the post even if the
pages returned *are* genuinely using 8859-1. It's hard to see how it
would be displayed in that case though.

If a character isn't in 8859-1, you won't be able to represent it in
8859-1.

Do you *have* to use 8859-1 rather than an encoding which can represent
the whole of Unicode (eg UTF-8)?

--
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 1 '07 #3
ThunderMusic <No*************************@NoSpAm.comwrote:
it's actually because we are sending mails to hotmail, and because our
application is in utf-8 and hotmail uses ISO-8859-1, so if we send a message
encoded using UTF-8, the displayed message comes out plain ugly in
hotmail...
Does Hotmail *really* only use ISO-8859-1? Eek - how horrible.
So we must find a way to convert things correctly... to give an exemple of
what should be converted... a character like the oe (o and e tied together)
should be converted to ISO-8859-1 oe (o and e separatly) because the "tied
together" version does not exists in 8859-1...

Anyone knows how to do it seemlessly?
Right. At that point you're talking about much more than just normal
encoding - and unfortunately we've reached the limit of my knowledge
there :(

--
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 1 '07 #4
You can encode your strings into ISO-8859-1 or into any other encoding
(see:)

http://msdn2.microsoft.com/en-us/lib...ng(d=ide).aspx
byte[] encodedString =
Encoding.GetEncoding("iso-8859-1").GetBytes("Whatever you want to
say");

// is the same as

byte[] encodedString = Encoding.GetEncoding(28591).GetBytes("Whatever
you want to say");

// then you can then write it to a FileStream
FileStream file = File.Create(fileName);
file.Write(encodedString, 0, encodedString.Length);

// you can also write to a StreamWriter directly
string fileName = pathToYourFile;
// false: overwrite, true: append
StreamWriter writer = new StreamWriter(fileName, false,
Encoding.GetEncoding("iso-8859-1"));
writer.WriteLine("Whatever you want to say");

Regards,
Joachim

Feb 1 '07 #5
jo*****@yamagata-europe.com <jo*****@yamagata-europe.comwrote:
You can encode your strings into ISO-8859-1 or into any other encoding
(see:)

http://msdn2.microsoft.com/en-us/lib...ng(d=ide).aspx
The problem is that the OP is trying to represent characters which
aren't actually in ISO-8859-1 though.

--
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 1 '07 #6
actually, hotmail supports 4 types of encoding, but not UTF-8 nor UTF-16, so
it's becoming a problem...

Thanks... I'm still searching for informations on the net...

ThunderMusic

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
ThunderMusic <No*************************@NoSpAm.comwrote:
>it's actually because we are sending mails to hotmail, and because our
application is in utf-8 and hotmail uses ISO-8859-1, so if we send a
message
encoded using UTF-8, the displayed message comes out plain ugly in
hotmail...

Does Hotmail *really* only use ISO-8859-1? Eek - how horrible.
>So we must find a way to convert things correctly... to give an exemple
of
what should be converted... a character like the oe (o and e tied
together)
should be converted to ISO-8859-1 oe (o and e separatly) because the
"tied
together" version does not exists in 8859-1...

Anyone knows how to do it seemlessly?

Right. At that point you're talking about much more than just normal
encoding - and unfortunately we've reached the limit of my knowledge
there :(

--
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 1 '07 #7

"ThunderMusic" <No*************************@NoSpAm.comwrote in message
news:u3**************@TK2MSFTNGP02.phx.gbl...
it's actually because we are sending mails to hotmail, and because our
application is in utf-8 and hotmail uses ISO-8859-1, so if we send a
message
encoded using UTF-8, the displayed message comes out plain ugly in
hotmail...

So we must find a way to convert things correctly... to give an exemple of
what should be converted... a character like the oe (o and e tied
together)
should be converted to ISO-8859-1 oe (o and e separatly) because the "tied
together" version does not exists in 8859-1...

Anyone knows how to do it seemlessly?
The discrepancy you are seeing in the way IE behaves is due to windows
drawing a correlation between the OEM codepage 1252 and the ISO-8859-1.
Windows-1252 is character set based on ISO-8859-1 in that all characters
have the same encoding except for characters in the 128-159 range. In this
range ISO-8859-1 has a set of control codes that are almost never used these
days. Windows-1252 borrows this area to squeeze in some extra characters.

When a page coming from source claiming ISO-8859-1 charset uses characters
in this range IE just renders the Windows-1252 characters for them. However
something sticking more strictly to ISO-8859-1 just doesn't know what to do
with them.

This doesn't solve your problem I know. If what you say is true then
hotmail is unable to communicate well with all it's possible clients.
That's so shocking it leaves me wondering whether there is something else
wrong.

Can you show some code you are using to generate the email?

Feb 2 '07 #8
If what you say is true then
hotmail is unable to communicate well with all it's possible clients.
That's so shocking it leaves me wondering whether there is something else
wrong.
I strongly-strongly doubt that hotmail is unable to handle UTF-8
Can you show some code you are using to generate the email?
Agree, most likely the probem is here :-)
From experience I know that the chances that I discov a bug in a compiler are
slim (happened two times only). So before blaming something on the compiler,
I check my code 30 times!

This is one of those. I am so sure that hotmail can handle utf-8, that I
would check my code 30 times :-)
--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email
Feb 2 '07 #9

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

Similar topics

48
by: Zenobia | last post by:
Recently I was editing a document in GoLive 6. I like GoLive because it has some nice features such as: * rewrite source code * check syntax * global search & replace (through several files at...
43
by: Vladimir | last post by:
Method UnicodeEncoding.GetMaxByteCount(charCount) returns charCount * 2. Method UTF8Encoding.GetMaxByteCount(charCount) returns charCount * 4. But why that? Look: /* Each Unicode character...
10
by: Christopher H. Laco | last post by:
Long story longer. I need to get web user input into a backend system that a) only grocks single byte encoding, b) expectes the data transer to be 1 bytes = 1 character, and c) uses the HP Roman-6...
5
by: DbNetLink | last post by:
I am trying to convert some Japanese text encoded as Shift-JIS/ISO-2022-JP to UTF-8 so I can store all data in my database with a common encoding. My problem is the encoding conversion code works...
9
by: Andy | last post by:
I am trying to write a for loop that will print all the ISO-Latin characters to a database. However: I am not sure exactly how to go about printing the ISO-Latin character set. Would anyone be...
9
by: Mark | last post by:
I've run a few simple tests looking at how query string encoding/decoding gets handled in asp.net, and it seems like the situation is even messier than it was in asp... Can't say I think much of the...
5
by: Michiel | last post by:
problem: pasting characters from MSWord into wysiwyg editor (tinyMCE) When we paste text from Word (i.e. MSWindows) to the browser, and in the text is any special character, like smart quotes,...
0
by: yuvalbra | last post by:
Hello , I work with asp and send email by cdonts and want to get in in 1255 ISO-Logical encoding every email i got the numbers shows backwords , i need to goto to encoding and replace to...
4
by: kettle | last post by:
Hi, I am rather new to python, and am currently struggling with some encoding issues. I have some utf-8-encoded text which I need to encode as iso-2022-jp before sending it out to the world. I am...
8
by: lisa1987i | last post by:
I am really having trouble with encoding characters. The application I am creating i based on a NNTP component from Smilla smilla.ru My propblem is when I read a string which contain special...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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,...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.