delphi TMemoryStream读取html文件中文乱码
procedure TFormLoadHtml.cxbtn2Click(Sender: TObject); var fileAllName: string; stream: TMemoryStream; begin if dlgOpen1.Execute then fileAllName := dlgOpen1.FileName
else
exit;
stream := TMemoryStream.Create; stream.LoadFromFile(fileAllName); cxm1.Lines.LoadFromStream(stream); stream.Free; end;
用notepad++打开发现html文件是utf-8格式,所以改成gbk 格式。同时需要修改html文件编码格式。
<head>
<meta charset="gb2312">
<title>ECharts</title>
</head>