UI/FormControlPreviewMessage.xaml.cs
changeset 2338 59b3afe16614
parent 2292 669e39629d45
child 2340 ef6f1ae3a234
equal deleted inserted replaced
2337:f2dd273a4b53 2338:59b3afe16614
   171                 string htmlString = this.displayState.Message.LongMsgFormattedHtml;
   171                 string htmlString = this.displayState.Message.LongMsgFormattedHtml;
   172 
   172 
   173                 // Ensure UTF-8 encoding
   173                 // Ensure UTF-8 encoding
   174                 try
   174                 try
   175                 {
   175                 {
   176                     Match m = Regex.Match(htmlString, "<head(.+?)<meta(.+?)content-type(.+?)>", RegexOptions.Singleline | RegexOptions.IgnoreCase);
   176                     Match m = Regex.Match(htmlString, @"<head(.+?)</head>|<head(.+?)<meta(.+?)content-type(.+?)>", RegexOptions.Singleline | RegexOptions.IgnoreCase);
   177                     if (string.IsNullOrEmpty(m?.Value))
   177                     if (string.IsNullOrEmpty(m?.Value))
   178                     {
   178                     {
   179                         Regex r = new Regex("<head(.*?)>", RegexOptions.IgnoreCase);
   179                         Regex r = new Regex("<head(.*?)>", RegexOptions.IgnoreCase);
   180                         Match m2 = r.Match(htmlString);
   180                         Match m2 = r.Match(htmlString);
   181                         if (string.IsNullOrEmpty(m2.Value))
   181                         if (string.IsNullOrEmpty(m2.Value))
   194                         {                            
   194                         {                            
   195                             utf8 = Regex.Replace(m.Value, "charset=(.+)'", "charset='utf-8'", RegexOptions.Singleline | RegexOptions.IgnoreCase);
   195                             utf8 = Regex.Replace(m.Value, "charset=(.+)'", "charset='utf-8'", RegexOptions.Singleline | RegexOptions.IgnoreCase);
   196                         }
   196                         }
   197                         else
   197                         else
   198                         {
   198                         {
   199                             utf8 = m.Value.Replace(">", " charset='utf-8'>");
   199                             Regex reg = new Regex(">");
       
   200                             utf8 = reg.Replace(m.Value, " charset='utf-8'>", 1);
   200                         }
   201                         }
   201                         
   202                         
   202                         Regex r = new Regex(".*", RegexOptions.IgnoreCase);
   203                         Regex r = new Regex(".*", RegexOptions.IgnoreCase);
   203                         htmlString = r.Replace(htmlString, utf8, 1);                        
   204                         htmlString = r.Replace(htmlString, utf8, 1);                        
   204                     }
   205                     }