UPDATE: I fixed this by loading the html string directly instead of first converting to a byte array.
So this:
became this:
When I save and reload using an HtmlFormatProvider I get strange results with Tab characters.
Here is an example where the original text is "a<tab>b<tab>c".
The first time it is saved it looks like this. The tabs have been replaced with two " ":
<style type="text/css">
.p_CC664AAA { margin: 0px 0px 12px 0px;text-align: left;text-indent: 0pt;padding: 0px 0px 0px 0px; }
.s_6BF1D20F { font-family: 'Calibri';font-style: normal;font-size: 16px;color: #000000; }
</style><p class="p_CC664AAA"><span class="s_6BF1D20F">a b c</span></p>
After reloading and saving again it looks like this. The two " " have been replaced with whitespace:
<style type="text/css">
.p_384D933F { margin: 0px 0px 0px 0px;text-align: left;text-indent: 0pt;padding: 0px 0px 0px 0px; }
.s_6BF1D20F { font-family: 'Calibri';font-style: normal;font-size: 16px;color: #000000; }
</style><p class="p_384D933F"><span class="s_6BF1D20F">a b c</span></p>
After reloading and saving again it looks like this. The whitespaces have been replaced with question marks:
<style type="text/css">
.p_384D933F { margin: 0px 0px 0px 0px;text-align: left;text-indent: 0pt;padding: 0px 0px 0px 0px; }
.s_6BF1D20F { font-family: 'Calibri';font-style: normal;font-size: 16px;color: #000000; }
</style><p class="p_384D933F"><span class="s_6BF1D20F">a? ? b? ? c</span></p>
Here is the sample code I am using for this test:
So this:
string text = File.ReadAllText(@"c:\temp\RichText.txt");
Byte[] convertedText = Encoding.ASCII.GetBytes(text);
RadDocument document = _htmlFormatProvider.Import(convertedText);
became this:
string text = File.ReadAllText(@"c:\temp\RichText.txt");
RadDocument document = _htmlFormatProvider.Import(text);
When I save and reload using an HtmlFormatProvider I get strange results with Tab characters.
Here is an example where the original text is "a<tab>b<tab>c".
The first time it is saved it looks like this. The tabs have been replaced with two " ":
<style type="text/css">
.p_CC664AAA { margin: 0px 0px 12px 0px;text-align: left;text-indent: 0pt;padding: 0px 0px 0px 0px; }
.s_6BF1D20F { font-family: 'Calibri';font-style: normal;font-size: 16px;color: #000000; }
</style><p class="p_CC664AAA"><span class="s_6BF1D20F">a b c</span></p>
After reloading and saving again it looks like this. The two " " have been replaced with whitespace:
<style type="text/css">
.p_384D933F { margin: 0px 0px 0px 0px;text-align: left;text-indent: 0pt;padding: 0px 0px 0px 0px; }
.s_6BF1D20F { font-family: 'Calibri';font-style: normal;font-size: 16px;color: #000000; }
</style><p class="p_384D933F"><span class="s_6BF1D20F">a b c</span></p>
After reloading and saving again it looks like this. The whitespaces have been replaced with question marks:
<style type="text/css">
.p_384D933F { margin: 0px 0px 0px 0px;text-align: left;text-indent: 0pt;padding: 0px 0px 0px 0px; }
.s_6BF1D20F { font-family: 'Calibri';font-style: normal;font-size: 16px;color: #000000; }
</style><p class="p_384D933F"><span class="s_6BF1D20F">a? ? b? ? c</span></p>
Here is the sample code I am using for this test:
public Form1()
{
InitHtmlFormatProvider();
InitializeComponent();
}
private static HtmlFormatProvider _htmlFormatProvider;
private static void InitHtmlFormatProvider()
{
_htmlFormatProvider = new HtmlFormatProvider();
var htmlExportSettings = new HtmlExportSettings();
htmlExportSettings.DocumentExportLevel = DocumentExportLevel.Fragment;
_htmlFormatProvider.ExportSettings = htmlExportSettings;
}
private void commandBarButtonLoad_Click(object sender, EventArgs e)
{
string text = File.ReadAllText(@"c:\temp\RichText.txt");
Byte[] convertedText = Encoding.ASCII.GetBytes(text);
RadDocument document = _htmlFormatProvider.Import(convertedText);
radRichTextBox1.Document = document;
}
private void commandBarButtonSave_Click(object sender, EventArgs e)
{
string html = _htmlFormatProvider.Export(radRichTextBox1.Document);
File.WriteAllText(@"c:\temp\RichText.txt", html);
}