Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading unicode characters from text file in Delphi 2009

I have the following piece of code to read Japanese Kanji characters from UTF-8 format Text file and then load it into Memo.

Var F:textFile;
S:string;
Begin
 AssignFile(F,'file.txt');
 Reset(F);
 While not EoF(F) do
 Begin
  Readln(F,S);
  Memo1.Lines.Add(S);
 End;
 CloseFile(F);
End;

But instead of characters I see some set of totally different symbols, not related to Japanese set. Any hints?

like image 715
Tofig Hasanov Avatar asked Feb 21 '10 18:02

Tofig Hasanov


1 Answers

Use Memo1.Lines.LoadFromFile, or LoadFromStream. TextFile is still using ANSI even in Delphi 2009.

like image 74
Ondrej Kelle Avatar answered Sep 16 '22 14:09

Ondrej Kelle