File Mover Blog

May 13, 2017

Code Page Identifiers

In Limagito v11.05.13.0 we’ve added the following function:

Function psSaveTxt2File(Text, Destination: String; Encoding: String; WriteBOM: Boolean): Boolean;

This function can be used to convert text file encoding. The ‘Encoding’ string var that needs to be passed to the function can be found in the name table in the following link:

msdn.microsoft.com

In the following example we’ll read the content of a text file (File Filter is set to only pickup .txt files) and save it using ‘ISO-8859-1’ encoding.

On Destination Pascal Script


var
aList: TStringList;
aString: String;
const
ctOutputPath = 'C:\Test\Out\';
Begin
psExitCode:= 1;
// ... add your code here
aList := TStringList.Create;
Try
Try
aList.LoadFromFile(psFilePath + psFileName);
// Save
psSaveTxt2File(aList.Text, ctOutputPath + psFileName, 'ISO-8859-1', False);
Except
psLogWrite(1, '', 'Pascal Script Exception');
End;
Finally
aList.free;
End;
End.

Best Regards,
Limagito Team

By Limagito-Team Parameters Share:
SEARCH