开发者

using the correct encoding for sending special characters to people using outlook

I was wondering what encoding format i should be using to send special characters in emails to people using outlook. I have done my own research and came accross ways to do things but none worked for me. I checked outlook and it seems that by default, it is usin开发者_如何学JAVAg Western European (Windows) format and is therefore using Windows-1252 Encoding (if what i searched and understood is correct). However, when i tried to convert from unicode in C# to the Windows-1252 encoding, my outlook is still not recognising the special characters to be legitimate. E.g below some random person's name:

expected result: Mr Moné Rêve

actual result (wrong): Mr Moné Rêve

Can anyone help me on what approach i should take to make the above correct.

My code:

string Fullname = "Mr Moné Rêve";
Encoding unicode = new UnicodeEncoding(); 
Encoding win1252 = Encoding.GetEncoding(1252); 

byte[] input = unicode.GetBytes(Fullname);      
byte[] output = Encoding.Convert(unicode, win1252, input);

string result = win1252.GetString(output);  


There is no "Correct" encoding. You should specify the charset in the HTML.

This is taken from an email that I have received (you can get the source from an email using for instance outlook):

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">

When you set an encoding on the document you have to specify what encoding you use, otherwise the receiver won't know which one you used. The declaration of the encoding can be read with whatever encoding you wish to use, thus the encoding can be read without knowing the encoding.

Read this about encodings and how they work: http://www.joelonsoftware.com/printerFriendly/articles/Unicode.html


In the end, i went for checking for special characters in my string and changing special characters into their code equivalent e.g é becomes &#233;


The best way is to convert them to their HTML entities. here is a tool called HTML Special Character Converter, it will help you convert special characters to their HTML entities width just one click.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜