Michael Schnell schreef:
I found that the current FPC does have Unicode support, but there are some problems.


I am going to give it another try, maybe it helps somebody.

- by design (for speed sake), UTF8String (and WideString when surrogate codes are used) count in subcodes and not in Unicode-Characters, so the behavior is "unexpected" when doing things like s[i], pos(s), copy(), delete(), ... There are not _slow_ functions that do the "expected" versions of s[i], pos(s), copy(), delete(), ... (I've yet to find out how I can print just the first character of an UTF8String :)

- there are different option on how the compiler expects the coding of the source file. Seemingly if it detects it to be UTF8 coded and a certain (otherwise correct) option is set, even "s := 'hallo äöü'; " does not work correctly as expected if s is a WideString. (Lazarus with default settings suffers from this problem).

Create a new lazarus project, drop a memo, button and edit on a form and add the lclproc unit. Create a button on click handler and add the following code:

procedure TForm1.Button1Click(Sender: TObject);
var
  w: widestring;
  i: integer;
begin
  w := UTF8Decode('hallo äöü');
  Edit1.Caption := UTF8Encode(w);
  Memo1.Clear;
  for i := 1 to UTF8Length(Edit1.Caption) do
    Memo1.Lines.Add(UTF8Copy(Edit1.Caption, i,1));
end;

IMHO, this is working fine.

Vincent
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to