Recent

Author Topic: UTF-8 support in Memo?  (Read 10011 times)

Zajec

  • Newbie
  • Posts: 2
UTF-8 support in Memo?
« on: January 04, 2007, 02:11:25 pm »
I use Memo to show user some text and allow changing this. Untortunately I have problems with reading this text again from Memo using Lines object. There is part of my code:

Code: [Select]
procedure TForm1.FormCreate(Sender: TObject);
var plik: TextFile;
var s: string;
begin
  AssignFile(plik, './pl.txt');
  Reset(plik);
  while not eof(plik) do
  begin
    Readln(plik, s);
    Memo1.Lines.Add(s);
  end;
  CloseFile(plik);
end;

procedure TForm1.Button1Click(Sender: TObject);
var i: integer;
begin
  for i:=0 to (Memo1.Lines.Count-1) do
  ShowMessage(Memo1.Lines.Strings[i]);
end;


Can you see something invalid there? File pl.txt exists of course. The problem is that I get weird Messages from program, where there are polish letters in pl.txt. You can download source of my test program and pl.txt from http://files.myopera.com/Zajec/usedonce/zajec.tar.bz2 (39KB).




P.S.
File pl.txt contains:
Code: [Select]
Teśt
óf

polish lettęrs
but messages I get from Lazarus are:
Quote
1) Teśt
2) f
3) null
4) null

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
RE: UTF-8 support in Memo?
« Reply #1 on: January 05, 2007, 12:13:27 am »
What operating system are you using?

On unixes you should use gtk 2 widgetset to have utf-8 support. On Windows you need to recompile LCL with a special option to get the very partially working support for utf-8.

More information here:

http://wiki.lazarus.freepascal.org/LCL_Unicode_Support

 

TinyPortal © 2005-2018