开发者

pound symbol in plain text email

开发者 https://www.devze.com 2023-01-18 17:38 出处:网络
I am trying to insert a pound symbol into a plain开发者_如何学JAVA text email using .net but it appears as £

I am trying to insert a pound symbol into a plain开发者_如何学JAVA text email using .net but it appears as £

Any ideas how I can fix this?

thanks


The only way to get it working is to make sure you encode the email with the same character encoding as to what you decode it with. In this case, you are encoding the email in UTF-8 but decoding it as if it was Latin-1. It might be overkill for this case, but The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets is a good read.

One solution is to add Content-Type: text/plain; charset=UTF-8 as a header.


Make sure the declared character encoding of the email matches the character encoding you are actually using.


Well, this depends on the character encoding you use for sending out your plaintext mails.

Remember, there is no such thing as plaintext - you always need to use an encoding, and there are many to choose from :-).

If you use an encoding that has a pound sign (Unicode encodings do, ASCII e.g. does not), then just output it normally, and it should work.

P.S. Also see this excellent article:

The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)


I realise it is two years since this thread was running, but clearly people still need an answer to this problem. My experience relates to 'plain text' e-mails, not HTML.

I have found that "Content-Type: text/plain; charset=UTF-8" does not work correctly. The charset itself needs to be in quotes as:

"Content-Type: text/plain; charset='UTF-8'"

Of course several other charsets will work perfectly well too.


Depends how you're inserting it, but a couple of options are...

$ 

or

Convert.ToChar(35);
0

精彩评论

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

关注公众号