編碼

2012-06-14 57 views
1

WP7 WebControl的人物我有這個小片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("&#x2013;", " - "); 

      // 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); 



     } 
    } 

我希望有人瞭解我的問題,可以幫助我。提前致謝!

+0

你用什麼C#?你標記了它,但是沒有用c#編寫代碼。如果相關,請添加它。 –

回答

0

我只是幫你跟我knowleges在網絡environements: 「一©」, 「A®」, 「A」,... =>數據是:如果顯示該char類型的

保存爲UTF-8,瀏覽器認爲他不得不處理ISO

如果顯示該char類型的

:「」 =>數據是保存在ISO和瀏覽器認爲他不必處理UTF-8。 PS:對不起,我的英文不好。

希望我能幫到你。