[fpc-devel] Unicode support - for the 20th time... ;-)
graemeg.lists at gmail.com
Thu Nov 20 10:06:06 CET 2008
We are seeing more and more "hacks" being applied to projects trying
to scramble around the missing FPC feature - no built-in Unicode
A simple example in Lazarus.... Loading a UTF-8 encoded file into a TMemo.
Normally you would write code as follows (for ANSI text):
Unfortunately that doesn't work if the file contains unicode content,
so the following "hack" is required which is quite nasty:
ls := TStringList.Create;
for i := 0 to ls.Count-1 do
ls[i] := UTF8Encode(ls[i]);
All that crap just to load a simple text file that contains unicode
content!!! :-( And the other problem is that the hack above assumes
the files content is UTF-8 encoded. If the content is UTF-16 encoded,
you need yet another hack. :-(
As far as I know the Unicode spec does mention a way of detecting the
encoding type (educated guess). As a second stage backup for GUI
toolkits, we can do the same as KDE or Qt has done in File Open/Save
dialogs. The user can specify an Encoding type from a combobox
overriding the auto-detect process.
So PLEASE lets finalize a Unicode strategy for Free Pascal!!! Like I
said before, I'm willing to help where I can - be that writing unit
tests or implementing some RTL functions. I don't know the deep
internals of FPC, but the RTL seems relatively easy enough to code.
Marco summarized earlier discussions, but still no clear conclusion!
FPC is getting more and more behind in this regard. And developers
need to keep adding ugly hacks as shown above into there application.
This causes double work for developers. Applying the hack now, then
after FPC one day has Unicode support, remove the hacks.
I'm also pretty sure I am not the only one that is willing to help
with this feature - many developers require Unicode support. And this
is just going to become more urgent as time goes by. So lets finalize
a design and start implementation. Pretty please. ;-)
- Graeme -
fpGUI - a cross-platform Free Pascal GUI toolkit
More information about the fpc-devel