This tool allows you to convert text files from one to another, making them compatible with different programs and operating systems.
Linux most likely uses UTF-8 and Windows uses ANSI
program convtext;
{$APPTYPE CONSOLE}
//source code for convtext
{$R *.res}
{$RESOURCE CONVTEXT-RES.RES}
uses
System.SysUtils,
windows,
classes;
var sl:tstringlist;
hf1,hf2:thandle;
function typeStr(stype:string):Tencoding;
begin
if comparetext('ansi',stype)=0 then
result:=tencoding.ANSI else
if comparetext('ascii',stype)=0 then
result:=tencoding.ASCII else
if comparetext('unicode',stype)=0 then
result:=tencoding.Unicode else
if comparetext('utf-7',stype)=0 then
result:=tencoding.UTF7 else
if comparetext('utf-8',stype)=0 then
result:=tencoding.UTF8 else
raise Exception.Create('Unknown Format Specified');
end;
begin
try
if paramcount<3 then
begin
writeln('Changes the encoding of a text file');
writeln('Usage: ',extractfilename(paramstr(0)),
' input_file output_flle [in_format] out_format');
writeln('Supported Formats:');
writeln('ANSI');
writeln('ASCII');
writeln('Unicode');
writeln('UTF-7');
writeln('UTF-8');
writeln;
write('Press enter to quit...');
readln;
exitprocess(0);
end;
sl:=tstringlist.Create;
if paramcount=4 then
sl.LoadFromFile(paramstr(1),TypeStr(paramstr(3)))else
sl.LoadFromFile(paramstr(1));
sl.SaveToFile(paramstr(2),typestr(paramstr(paramcount)));
writeln(syserrormessage(0));
hf1:=createfile(pchar(paramstr(1)),generic_read,0,nil,open_existing,
file_attribute_normal,0);
hf2:=createfile(pchar(paramstr(2)),generic_read,0,nil,open_existing,
file_attribute_normal,0);
writeln('Original filesize: ',getfilesize(hf1,nil),' bytes');
writeln('Converted filesize: ',getfilesize(hf2,nil),' bytes');
writeln('Converted Percentage: ',round(100*(getfilesize(hf2,nil)/getfilesize(hf1,nil))),'%');
closehandle(hf1);
closehandle(hf2);
{ TODO -oUser -cConsole Main : Insert code here }
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
The short URL of the present article is: https://delphijustin.biz/go/wz29

Circuit Simulator