S
snfa
Unregistered / Unconfirmed
GUEST, unregistred user!
同样这段代码读unicode文本文件就可以,大家帮看看
var
pBuffer: PByte;
ff,pwChr: pWideChar;
strmScript: TMemoryStream;
sScript: string;
i:integer;
begin
strmScript:=TMemoryStream.Create;
TBlobField(adoQuery1.FieldByName('blob')).SaveToStream(strmScript);
GetMem(pBuffer, strmScript.Size);
try
strmScript.Read(pBuffer^, strmScript.Size);
pwChr:=pWideChar(pBuffer);
//Inc(pwChr,2);
sScript :=WideCharToString(pwChr);
SetLength(sScript,strmScript.Size div 2);//必须限制大小否则有乱码
ShowMessage(IntToStr(strmScript.Size));
Memo1.Text :=sScript;
RichEdit1.Lines.Text:=sScript;
finally
FreeMem(pBuffer);
strmScript.Free;
end;
var
pBuffer: PByte;
ff,pwChr: pWideChar;
strmScript: TMemoryStream;
sScript: string;
i:integer;
begin
strmScript:=TMemoryStream.Create;
TBlobField(adoQuery1.FieldByName('blob')).SaveToStream(strmScript);
GetMem(pBuffer, strmScript.Size);
try
strmScript.Read(pBuffer^, strmScript.Size);
pwChr:=pWideChar(pBuffer);
//Inc(pwChr,2);
sScript :=WideCharToString(pwChr);
SetLength(sScript,strmScript.Size div 2);//必须限制大小否则有乱码
ShowMessage(IntToStr(strmScript.Size));
Memo1.Text :=sScript;
RichEdit1.Lines.Text:=sScript;
finally
FreeMem(pBuffer);
strmScript.Free;
end;