LazUtils: improve unicode path/filename handling by Fileutil.ReadFileToString, patch from Takeda Matsuki, bug #22953

git-svn-id: trunk@38816 -
This commit is contained in:
maxim 2012-09-24 20:32:19 +00:00
parent 984207646b
commit 9a487a2e50

View File

@ -1543,15 +1543,15 @@ end;
------------------------------------------------------------------------------}
function ReadFileToString(const Filename: String): String;
var
fs: TFileStream;
fs: TFileStreamUTF8;
begin
Result := '';
try
fs := TFileStream.Create(UTF8ToSys(Filename), fmOpenRead or fmShareDenyWrite);
fs := TFileStreamUTF8.Create(Filename, fmOpenRead or fmShareDenyWrite);
try
Setlength(Result, fs.Size);
if Result <> '' then
fs.Read(Result[1], Length(Result));
fs.Read(Result[1], UTF8Length(Result));
finally
fs.Free;
end;