我有一个EurekaLog错误报告显示EEncodingError.日志指向TFile.AppendAllText.我打电话TFile.AppendAllText是我的这个程序:
procedure WriteToFile(CONST FileName: string; CONST uString: string; CONST WriteOp: WriteOpperation; ForceFolder: Boolean= FALSE); // Works with UNC paths
begin
if NOT ForceFolder
OR (ForceFolder AND ForceDirectoriesMsg(ExtractFilePath(FileName))) then
if WriteOp= (woOverwrite)
then IOUtils.TFile.WriteAllText (FileName, uString)
else IOUtils.TFile.AppendAllText(FileName, uString);
end;
Run Code Online (Sandbox Code Playgroud)
这是来自EurekaLog的信息.
是什么导致这种情况发生?
我有一个UTF-8格式的INI文件.
我正在使用Delphi 2010读取INI文件并使用INI文件中的值填充TStringGrid.
var
ctr : Integer;
AppIni : TIniFile;
begin
AppIni := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'test.ini');
for ctr := 1 to StringGrid1.RowCount do begin
StringGrid1.Cells[0,ctr] := AppIni.ReadString('Column1','Row'+IntToStr(ctr),'');
StringGrid1.Cells[1,ctr] := AppIni.ReadString('Column2','Row'+IntToStr(ctr),'');
end;
AppIni.Free;
Run Code Online (Sandbox Code Playgroud)
问题是unicode字符出现在TStringGrid中,显示2个字符,而不是1个unicode字符.
我该如何解决这个问题?
的结果GetParent('c:\1\2\')是'c:\1\2'。
的结果GetParent('c:\1\2')是'c:\1'。
这是正常/预期的行为吗?如果是,其背后的逻辑是什么?