简体   繁体   中英

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 using 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. Eg 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

最后,我去检查字符串中的特殊字符并将特殊字符更改为它们的等效代码,例如 é 变为&#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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM