2012-09-19 108 views
1

我使用System.Net.Mail,並且正在閱讀HTML到電子郵件正文中。在html電子郵件中的撇號字符不顯示

不幸的是,撇號字符'顯示爲黑色背景的問號。

我試圖用html '替換撇號,但是這仍然顯示黑色背景的問號。其他Html標籤(h1,p等)工作正常。

我現在必須有一個非常明顯的答案,但我似乎無法找到它。謝謝你的幫助。

UPDATE

看來,它就是導致我的問題就是System.IO.StreamReader。

using (StreamReader reader = new StreamReader("/Email/Welcome.htm")) 
{ 
    body = reader.ReadToEnd(); 
    //body string now has odd question mark character instead of apostrophe. 
} 
+1

看起來像一個編碼的問題,我... – TGlatzer

+0

我沒有做任何編碼自己。只需在包含文本的.htm文件中閱讀並標記即可。在Chrome,IE和Firefox中打開時.htm文件中的撇號看起來很好 –

+2

也許它不是'''(+編碼問題) –

回答

2

如果你知道你的文件的encoding你將要傳遞到您的StreamReader初始化:

using (StreamReader reader = new StreamReader("/Email/Welcome.htm", "Windows-1252")) 
{ 
    body = reader.ReadToEnd(); 
    // If the encoding is correct you'll now see ´ rather than � 
    // Which, by the way is the unicode replacement character 
    // See: http://www.fileformat.info/info/unicode/char/fffd/index.htm 
} 
0

您需要將此文件保存爲unicode utf-8格式才能正確使用。

+0

謝謝,我試過了,但它沒有沒有工作。我已經更新了我的問題,確切地說我得到問題的位置。 –

相關問題