I volunteered to find the solution to the current Lazarus problems.
All Lazarus users would profit and this case would be closed finally.
Utf8 supporters would have a safe and simple solution:
String can be alias of utf8String in unit scope. (requires FPC support)
Exactly, it is an FPC issue. You are not the first person with that idea. I also mentioned in one thread here that it would be the cleanest solution in the long run.
Right now it is not realistic. FPC team is building the UTF-16 RTL and other missing parts. Maybe also you will be happy with the fully Delphi compatible system when it comes out.
A new compiler mode with String = UTF8String can happen after the UTF-16 solution is ready and Unicode is replacing the old system codepages everywhere. Even then it needs somebody to do it. Nothing happens without people who actually implement things, you know.
The Lazarus UTF-8 hack can be seen as a proof of concept helping to design the new mode. Now the old codepages are assumed in many places, all code must be studied. It is not trivial.
If you really want to volunteer to improve things, please study the code in FPC and/or Lazarus and provide patches.
I don't think anybody will be against a new compiler string UTF-8 mode if you decide to implement it.
Your utf8 alternative (forever?) is unsafe and needs a wiki page with workarounds if possible (if source is not closed).
It is
not unsafe! Yes, it needs some workarounds and it is not 100% Delphi compatible, but it is as safe as other Unicode solutions.
From your earlier message:
It is unsafe because many units (also closed source, third parties) can change the global codepage (the heart of your string) any time.
That is nonsense. How can a unit in your project do such thing without you knowing? Even if you use third party libs without source, you must trust them. If a unit really wants to be malicious, it can do much worse things than change a codepage. Just use your imagination ...
Besides, how is it the fault of Lazarus if you have malicious third party libs?
And it is also unsafe at compiletime as you can see with "Don't use {$Codepage UTF8}", and I could continue with parameter passing
between libraries and other things.
"Don't use {$Codepage UTF8}" does not make it any less safe. Why would it? You are quite desperate to find something to complain.
Parameter passing goes fine when you use proper string type (eg. UnicodeString) or convert a system codepage with a SetCodePage() call. Why do I need to repeat this sentence so many times?
The current Unicode situation is this:
Many years were wasted discussing and arguing about FPC's Unicode solution. Because RTL and other libs do not support UTF-16 yet, a clever solution was created so that Lazarus can change the String default encoding and continue to use UTF-8 as always but in a more clever way. And frankly, it works better than anybody could expect.
Anyway, that is the solution we will have in near future. Just bashing it does not help anybody. It only wastes time and energy from many people, including both you and me.
If you deside to still use Lazarus in future, please attach your problematic code and an explanation of the problem so it can be solved.
Using Delphi is also a valid option if Lazarus does not suit your needs, as you mentioned yourself.