procedure MoveData(FileName,FieldNames,TableName:string);
var
Q:TFDQuery;
begin
fList.LoadFromFile(FileName,TEncoding.ANSI);
ShowMessage(fList.Text); //文字显示正常
Q:=TFDQuery.Create(Self);
Q.Connection:=TheConnection;
Q.SQL.Clear;
Q.SQL.Add(Format('Select %s From %s',[FieldNames,TableName]));
FDDataSetWriter.DataSet:=Q;
FDTextReader.FileName:=FileName;
FDTextReader.DataDef.WithFieldName:=true;
FDTextReader.Encoding:=ecANSI; //Encodint为ecANSI或ecDefault结果一样,为ecUTF8或ecUTF16则报错“Bad Text Value [1,22,"L]format for mapping item [ID].'1,22,"L' is not a valid integer value”
FDBatchMove.Reader:=FDTextReader;
FDBatchMove.Writer:=FDDataSetWriter;
FDBatchMove.Mode:=dmAlwaysInsert;
FDBatchMove.Options:=FDBatchMove.Options+[poClearDest];
FDBatchMove.Execute; //在Android下执行,导入的数据中,所有字段中的汉字都乱码
Q.Free;
end;
以上代码,在Win7+Delphi11中运行,结果正常。
但相同代码在Android+Delphi11环境下,虽然可以顺利执行,但导入的数据中,所有字段中的汉字都乱码。
请各位帮忙看看是什么问题,怎么解决?
谢谢!