identifier not found TEncoding

identifier not found "TEncoding"

I want to save the text in UTF or SJIS, but the following code causes an error at compile time.

Is there any other way to avoid it?


procedure TForm1.WebButton1Click(Sender: TObject);
var
Save_fileName:String;
fList : TStringList;
begin
Save_fileName:='test.csv';
fList:=TStringlist.create;

fList.add( 'JAPANESE'+'日本語' );

flist.SaveToFile(Save_fileName,TEncoding.UTF8);

flist.free;

end;


Delphi 10.4.1
TMS WebCORE 15.6.0

In web there is no encoding parameter for SaveToFile(), it is by default UTF8.

Thank you,
Here, it seems to be UTF8-N, and when you open it in Excel, Japanese characters are garbled.

This depends on how you open this in Excel. You need to specify the encoding:
image
then as you can see, it opens correct.
Opening this file in Notepad or other text file editors opens correct
image

いつも、ありがとうございます、

日本では、Excelは人気なので、ダイレクトにオープンを希望される方も多いと思います。
私もExcelの使用方法を勉強します。

I am always grateful for your help,

in this attached project
From WebHttpRequest1RequestResponse of WebHttpRequest1 by pressing
WebButton2, WebMemo2.Text: = AResponse;
will do
Is it possible to read this WebMemo2.txt directly into WebTableControl2?
Or is it not possible to easily read into WebStringGrid1?

//--------------------------------------------------------------------
procedure TForm1.WebHttpRequest1RequestResponse(Sender: TObject;
ARequest: TJSXMLHttpRequestRecord; AResponse: string);
var
wJSON_Root_Element: string;
begin
WebMemo2.Text:=AResponse;

//I want to realize this kind of thing!
wJSON_Root_Element := 'ROW';
WebTableControl2.LoadFromJSON(AResponse);
//I want to realize this kind of thing!
WebTableControl2.LoadFromCSV(AResponse);
end;
//--------------------------------------------------------------------
procedure TForm1.WebButton3Click(Sender: TObject);
begin
//I want to realize this kind of thing!
WebTableControl2.LoadFromCSV(WebMemo2.Text);
end;
//--------------------------------------------------------------------

087_WebTableControl_Q2.zip (1.63 MB)

LoadFromJSON() has two possible uses

  1. string parameter: LoadFromJSON(URL)
    Here you need to specify an URL!
  2. TJSObject parameter : LoadFromJSON(jsobject)
    Here you need to pass a JSON array
    So, in your case, you will need to parse the string response to a TJSObject and pass this to LoadFromJSON()