Declined
Last Updated: 13 Apr 2020 09:11 by ADMIN
Deepa
Created on: 13 Apr 2020 03:57
Category: WordsProcessing
Type: Bug Report
0
RTFProcessing: different out put for Windows and Linux

We are using the Telerik Xamarin UI components, which were released on 18th March 2020, for one of our micro-services hosted in Azure cloud, to convert rtf text to raw text. Currently we have Linux containers in Azure. The code which we are using is as follows -

var rtfFormatProvider = new RtfFormatProvider();

var txtFormatProvider = new TxtFormatProvider();

RadFlowDocument doc = null;

doc = rtfFormatProvider.Import(<<Base64_Inputstring>>.DecodeFromBase64String());

string result = txtFormatProvider.Export(doc);

However, we observed that the output of the above code is different when run on Windows platform as compared to when run on Linux platform. For Linux, the CR characters are not included in the raw text. We would like to see the same output for Linux as what we get for Windows, that is raw text with the CR characters. Is this something which can be fixed? Can you suggest a work-around for this issue?

I am attaching a sample input along with this mail, as well as the Windows output and the Linux output, for your reference.

Thanks,

Deepa 

 

 

1 comment
ADMIN
Martin
Posted on: 13 Apr 2020 09:11

Hello Deepa,

The reason for this behavior is that in the Unix and Unix-like systems (e.g. Linux) a single LF character (escape sequence: \n) was chosen as the newline marker while MS-DOS chose CR+LF (escape sequence: \r\n), and Windows inherited this. Different platforms use different conventions and different escape sequence is generated when using System.Environment.NewLine property. So this is an expected behavior, thus, I am declining this bug report.

As a possible workaround, I would suggest is to replace the LF character with CR+LF characters for Unix platforms. Check the following code snippet:

string result = txtFormatProvider.Export(doc);
if (IsLinux())
{
	result = result.Replace("\n", "\r\n");
}

Regards,
Martin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.