我有一小段 HTML
<b>OBNUBIL�,</b>
<abbr class="abbrev" title="persoană">pers.</abbr>
3 <i>obnubilează,</i>
<abbr class="abbrev" title="verb">vb.</abbr>
I. <abbr class="abbrev" title="reflexiv">Refl.</abbr>
(Rar; despre vedere, memorie) A se �ntuneca, a slăbi, a se umbri. Din
<abbr class="abbrev" title="limba latină">lat.</abbr>
<b>obnubilare,</b>
<abbr class="abbrev" title="limba franceză">fr.</abbr>
<b>obnubiler.</b>
我想在用 C# 编写的 Windows Phone 应用程序上的 WebBrowser 中显示它。这段 HTML 存储在一个字符串中:str2.
我使用了这行代码:webBrowser1.NavigateToString(str2)
. 它有效Romanian diacritics (ă ,ș ,ț,�, � ,Ă,Ț ,�,�,Ș)
,但未显示。
如何在 Windows Phone 中将 WebControl 的字符编码从 UTF-8 更改为 ISO-8859-16?
private void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
// Showing the exact error message is useful for debugging. In a finalized application,
// output a friendly and applicable string to the user instead.
MessageBox.Show(e.Error.Message);
});
}
else
{
string textString = (string)e.Result;
string fixedString = "";
// This search returns the substring between two strings, so
// the first index is moved to the character just after the first string.
string defStart = "cuvânt\">";
string defEnds = "</span> <br/>";
textString = textString.Replace("\r", "").Replace("\n", "");
int first = textString.IndexOf(defStart) + defStart.Length;
int last = textString.LastIndexOf(defEnds);
string str2 =textString.Substring(first, last - first);
str2 = str2.Replace("–", " - ");
// Remove tab spaces
str2 = str2.Replace("\t", " ");
// Remove multiple white spaces from HTML
str2 = Regex.Replace(str2, "\\s+", " ");
//str2 = Regex.Replace(str2, "<[^>]+>", string.Empty);
//BannerTextBlock.Text=str2;
webBrowser1.NavigateToString(str2);
}
}
我希望有人理解我的问题并可以帮助我。提前致谢!