Encoding Issue on TempBlob.Blob.CreateInStream ?
Hi, my first post here, I will try my best, I think I found a bug, but maybe I'm doing something wrong too.
I'm trying to export data to a csv file through the csvbuffer in an extension for Sandbox on http://businesscentral.dynamics.com, but I can't get the encoding to be Windows instead of UTF-8 no matter what I do.
This means my Danish characters (ÆØÅ) get messed up if you try and open the file in eg. Excel, as the default expected encoding is Windows. It works if I import it as text file and manually select UTF-8 as encoding. I thought TextEncoding::Windows should fix it, but it doesn't work for me.
Example below, am I doing something wrong, or is it a bug?
csvbuffer: Record "CSV Buffer" temporary;
tempblob: Record TempBlob temporary;
InStr: InStream;
ClientFileName: Text;
begin
csvbuffer.InsertEntry(1,1,'THIS IS DANISH LETTERS:ÆØÅæøå');
csvbuffer.SaveDataToBlob(tempblob,';');
TempBlob.Blob.CreateInStream(inStr,TextEncoding::Windows);
ClientFileName := 'encoding.csv';
DownloadFromStream(InStr,'Download','','*.csv|*.csv',ClientFileName);
end;
Hi @podgaard ! I think the documentation is outdated. The part about If you set the text encoding to Windows, you can import and export text files that are based on the Windows codepage on the user’s computer. only applies if the user is running the Windows client. If the user is using the web-client and you set the text encoding to Windows, the server's default encoding is used, which is English.
Hi @podgaard ! I think if you try to put Textencoding on outsream then it should work, i did this on NAV 2018 webclient using AL extension. earlier using your code I was getting the same challenge but if you put the encoding on OutStream then it is working fine for me , also I don't have SaveDataToBlob to function in my build so you might have to change the code there it self or may be you can do that by making a replica of this function. @atoader : if this work then can we put this on the W1 build if possible to avoid this issue in future? (only if the SaveDataToBlob function is in the W1 build)

@rishiaurrishabh Thanks this helped and solved my issue ! So I guess my request if anything, would be to make csvbuffer.SaveDataToBlob have a parameter that sets the encoding, like you can when you write text to the OutStream.
@atoader Thanks also for response.
@all I will close this issue I guess.