procedure SaveAnsiEncodedTextFileFromTempBlob(var TempBlobLocal: Codeunit "Temp Blob"; FileName: Text)
var
InStream, IStream : InStream;
OutStream: OutStream;
TempBlobLocal2: Codeunit "Temp Blob";
TextToWrite: Text;
i: Integer;
Byte1, Byte2, Byte3, Byte4, Byte5, Byte6 : Byte;
begin
// Read text from TempBlob
TempBlobLocal.CreateInStream(InStream, TextEncoding::UTF8);
InStream.ReadText(TextToWrite);
TempBlobLocal2.CreateOutStream(OutStream);
Byte1 := 230; // æ
Byte2 := 248; // ø
Byte3 := 229; // å
Byte4 := 198; // Æ
Byte5 := 216; // Ø
Byte6 := 197; // Ã…
for i := 1 to StrLen(TextToWrite) do begin
if TextToWrite[i] = 'æ' then
OutStream.Write(Byte1)
else if TextToWrite[i] = 'ø' then
OutStream.Write(Byte2)
else if TextToWrite[i] = 'Ã¥' then
OutStream.Write(Byte3)
else if TextToWrite[i] = 'Æ' then
OutStream.Write(Byte4)
else if TextToWrite[i] = 'Ø' then
OutStream.Write(Byte5)
else if TextToWrite[i] = 'Ã…' then
OutStream.Write(Byte6)
else
OutStream.Write(TextToWrite[i]);
end;
// Save the file
TempBlobLocal2.CreateInStream(IStream);
DownloadFromStream(IStream, '', '', '', FileName);
end;