NET Core Version : 3.1.405 Windows version: Windows 10
The RichTextBox cannot convert non ascii chars from my rtf string in my WPF application.
string rtf ="{\\rtf1\\ansi\\ansicpg1252\\uc1\\htmautsp\\deff2{\\fonttbl{\\f0\\fcharset0 Times New Roman;}{\\f2\\fcharset0 Arial;}} {\\colortbl\\red0\\green0\\blue0;\\red255\\green255\\blue255;}\\loch\\hich\\dbch\\pard\\plain\\ltrpar\\itap0{\\lang32\\fs30\\f2\\cf0 \\cf0\\qj\\sl15\\slmult0{\\f2 {\\ltrch entête}\\li0\\ri0\\sa0\\sb0\\fi0\\qj\\sl15\\slmult0\\par}}}"
if (rtf.Length > 2)
{
FlowDocument flowDocument = new FlowDocument
{
LineHeight = 1,
Language = XmlLanguage.GetLanguage(Thread.CurrentThread.CurrentUICulture.Name),
};
using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(rtf)))
{
TextRange text = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd);
if (stream.Length != 0)
{
text.Load(stream, DataFormats.Rtf);
}
text.ClearAllProperties();
}
return flowDocument;
}
Actual behavior : My RichTextbox display "Entête ". Problem with the conversion of "ê" (non ASCII chars)
Expected behavior: My RichTextbox display "Entête ". Problem with the conversion of "ê"