I've got a WPF RichTextBox which loads RTF content perfectly (English characters). The problem comes when trying to set Japanese characters (e.g. ユーザに) into the editor. When doing this, the result is the following:
It seems something about the Encoding ... so I adapted my code to use Unicode instead of UTF8. Anyway, it's not working. My code to load text into the RTF editor is as simple as follows:
private void Window_Loaded(object sender, RoutedEventArgs e) {
string text = "ユーザに";
TextRange textRange = new TextRange(MyRichTextBox.Document.ContentStart, MyRichTextBox.Document.ContentEnd);
textRange.Load(new MemoryStream(Encoding.Unicode.GetBytes(text)), DataFormats.Rtf);
}
Finally, the XAML layout does not have anything special:
<Window x:Class="Tester.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Loaded="Window_Loaded"
Title="MainWindow" Height="350" Width="525">
<Grid>
<RichTextBox x:Name="MyRichTextBox" Margin="3"></RichTextBox>
</Grid>
</Window>
Just in case it helps ... I've got installed the Japanese language in this computer, and it looks good. Furthermore, if I paste (ctrl+v) Japanese characters on the editor once it's loaded, it appears to work.
Thanks in advance!

