We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Incorrect target file encoding

Hi. I’m using Aspose.Cells 8.7.2 for .NET 4.5.2

const string sourceText = “Text”;
const string targetText = “هل تتردد إلى هذه الصفحة كثيرًا؟ اجعل”;
var sourceEncoding = Encoding.ASCII;
var targetEncoding = Encoding.UTF8;

using (
MemoryStream sourceStream = new MemoryStream(sourceEncoding.GetBytes(sourceText)),
targetStream = new MemoryStream())
{
{
var workbook = new Workbook(sourceStream, new TxtLoadOptions(LoadFormat.CSV) { Encoding = sourceEncoding });
var worksheet = workbook.Worksheets.Single();
worksheet.Cells.FirstCell.PutValue(targetText);

worksheet.Workbook.Save(targetStream, new TxtSaveOptions(SaveFormat.CSV) { Encoding = targetEncoding });
}
{
targetStream.Position = 0;
var workbook = new Workbook(targetStream, new TxtLoadOptions(LoadFormat.CSV) { Encoding = targetEncoding });
var text = workbook.Worksheets.Single().Cells.FirstCell.StringValue;

Console.WriteLine(text == targetText);

targetStream.Position = 0;
var preamble = new byte[targetEncoding.GetPreamble().Length];
targetStream.Read(preamble, 0, preamble.Length);
Console.WriteLine(targetEncoding.GetPreamble().SequenceEqual(preamble));
}
}
This program prints ‘False’ both times. But if you change sourceEncoding to some uncoding encoding (say, UTF-32), then the program works correctly and prints ‘True’ both times.

Hi,


Thanks for providing us some details with sample code.

I have tested your scenario/ case manually. I did create the CSV file manually in MS Excel containing the text “هل تتردد إلى هذه الصفحة كثيرًا؟ اجعل” with your desired “US_ASCII” but the arabic text are converted to “???..”, so I think it is not possible to create a CSV file containing your target text with ASCII encoding type. If you think otherwise, kindly do create a CSV file with your desired target text and encoding type manually, save the file and post us here, we will check it soon.

Thank you.

Hi.
Source file in ASCII encoding does not contain arabic text, but a simple english text “Text”.
The idea is to take a valid file in ASCII encoding, put some arabic text, save the file in UTF-8 and still get ASCII encoding in output file

Hi,


We are not sure if this is an issue with Aspose.Cells component. It looks like source encoding (for the template CSV file) is more important and takes into account when inserting arabic text. We need to evaluate it thoroughly and discuss the matter with the product team. As requested earlier, could you create a sample CSV file with your desired target text and encoding type manually in MS Excel, save the file and post us here, it will help us to look into your issue precisely.

Thank you.

Hi,


I did discuss your issue with the concerned developer from product team. We confirmed the the issue is with Aspose.Cells component. We found an incorrect encoding with the saved (CSV) file when inserted arabic text as you pointed out. I have logged a ticket with an id “CELLSNET-44375” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.

Thank you.

Hi,

It is to inform you that we have fixed your issue CELLSNET-44375 now. We will soon provide the fix after performing QA and including other enhancements and fixes.


Thank you.

Hi,

Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for .NET v8.7.2.5 and let us know your feedback.

The issues you have found earlier (filed as CELLSNET-44375) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.