[fpc-devel] Unicode support (again)
vsnijders at vodafonevast.nl
Mon Nov 10 17:00:28 CET 2008
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);
w := UTF8Decode('hallo äöü');
Edit1.Caption := UTF8Encode(w);
for i := 1 to UTF8Length(Edit1.Caption) do
IMHO, this is working fine.
More information about the fpc-devel