代碼: 選擇全部
function WriteWideString2File(filename: string; ws: WideString):Boolean;
const
WideBOM_LSB_First = WideChar(#$FEFF);
var
wf: WideString;
f: TFileStream;
i: integer;
begin
Result := false;
wf := WideBOM_LSB_First;
f:= TFileStream.Create(filename, fmCreate);
try
f.Write(wf[1], 2);
//for i:= 1 to length(ws) do
// f.Write(ws[i], sizeof(ws[i]));
f.Write(PWideChar(ws)^, length(ws)*sizeof(WideChar));
Result := true;
finally
f.Free;
end;
end;
參考文章: http://delphi.ktop.com.tw/topic.asp?TOPIC_ID=46228