Hello! I have a question with the handling of strings. Punctually, the length of the same with accented characters.
Please look at attachament.
In the attachment you can see a screenshot, from the code below. Where there are two TEdit with the same text (with the difference that in one of them, this one with accents), but the length of the same is different, I thought that could be the codification, but both are in UTF8.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, LConvEncoding;
type
{ TForm1 }
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
procedure Edit1Change(Sender: TObject);
procedure Edit2Change(Sender: TObject);
procedure FormShow(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Edit1Change(Sender: TObject);
begin
Label1.Caption:='Length: '+intToStr(Length(edit1.Text))+' GuessEncoding: '+GuessEncoding(edit1.Text);
end;
procedure TForm1.Edit2Change(Sender: TObject);
begin
Label2.Caption:='Length: '+intToStr(Length(edit2.Text))+' GuessEncoding: '+GuessEncoding(edit2.Text);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Edit1Change(self);
Edit2Change(self);
end;
end.
Thanks!