我想是跟編碼有關係(假設你的作業系統是繁體的,那在delphi畫面中,如果用預設的字集,將無法顯示GB碼的字)
建議去參考一下unicode 補完計劃(google搜尋就找得到),安裝之後,也許馬上就能解決您的問題。
或是去找一下GB轉BIG5的工具或是函數,先轉換編碼,再顯示到畫面上。
以上是小弟個人淺見,若有錯誤請指教。
===================引 用 文 章===================
txt檔內容如下
A001#当大多数80后还处于懵懂和幻想阶段的时候#112臺北市公館路60號5樓#02-23241156#北區
A002#幻想阶段的时候#806高雄市大安路一段22號#07-7644321#南區
A003#当大多数80后还处于#100新竹市中山北路二段115號11樓之#302-23445731#北區
程式碼如下:執行後的StringGrid資料都變亂碼,怎麼辦?
拜託指導
procedure TForm1.BitBtn6Click(Sender: TObject);
var
i, count : Integer;
F : textFile ;
str : widestring;
ans : array[1..5] of string;
row : Integer;
begin
StringGrid1.RowCount := 2;
StringGrid1.Cells[0,0] := '編號';
StringGrid1.ColWidths[0] := 50;
StringGrid1.Cells[1,0] := '公司名稱';
StringGrid1.ColWidths[1] := 100;
StringGrid1.Cells[2,0] := '地址';
StringGrid1.ColWidths[2] := 250;
StringGrid1.Cells[3,0] := '電話';
StringGrid1.ColWidths[3] := 100;
StringGrid1.Cells[4,0] := '地區';
StringGrid1.ColWidths[0] := 40;
//
if FileExists(datafile) then
begin
AssignFile(F,datafile);
Reset(F);
row := 1;
try
while not EOF(F) do
begin
Readln(F,str); ----->程式執行到此 str這個變數已是亂碼
count := 1;
for i := 1 to 5 do ans[i] := '';
for i := 1 to length(str) do
if str[i] <> '#' then
ans[count] := ans[count] str[i]
else
count := count 1 ;
StringGrid1.Cells[0,row] := ans[1];
StringGrid1.Cells[1,row] := ans[2];
StringGrid1.Cells[2,row] := ans[3];
StringGrid1.Cells[3,row] := ans[4];
StringGrid1.Cells[4,row] := ans[5];
Inc(row);
StringGrid1.RowCount := row;
end;
finally
CloseFile(F);
end;
end;
end;