{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
ShareMem,
SysUtils,
Classes;
{$R *.res}
procedure saveaswstr(f1:string);stdcall; //将文件f1转换为unicode编码
var
t1:TStringList; FileStream: TFileStream;
P: pchar;
W: WideString;
begin
t1:=TStringList.Create;
t1.LoadFromFile(f1);
procedure WordLoHiExchange(var w:Word);
var
b:Byte;
begin
b:=WordRec(w).Lo;
WordRec(w).Lo:=WordRec(w).Hi;
WordRec(w).Hi:=b;
end;
procedure saveastxt(f2:string);stdcall; //将unicode big endian转换为ansi格式存储
var
buffer: WideChar;
f: file of WideChar;
str: string;
w:word;
t1:TstringList;
begin
t1:=TstringList.Create;
assignfile(f, f2);
reset(f);
read(f, buffer); // 跳过unicode开头的标记
while not eof(f) do
begin
read(f, buffer);
w:=word(buffer);
WordLoHiExchange(w);
buffer:=widechar(w);
procedure WordLoHiExchange(var w:Word);
var
b:Byte;
begin
b:=WordRec(w).Lo;
WordRec(w).Lo:=WordRec(w).Hi;
WordRec(w).Hi:=b;
end;
procedure saveastxt(f2:string);stdcall; //将unicode big endian转换为ansi格式存储
var
buffer: WideChar;
f: file of WideChar;
str: string;
w:word;
t1:TstringList;
begin
t1:=TstringList.Create;