[Lazarus] UTF8String and UTF8Delete

Jürgen Hestermann juergen.hestermann at gmx.de
Sat Dec 12 17:37:05 CET 2015


Am 2015-12-12 um 17:16 schrieb wkitty42 at windstream.net:
> On 12/12/2015 10:47 AM, Bart wrote:
>> Anyhow, as stated before, there should be noneed to use the type
>> Utf8String in Lazarus programs.
>
> i've been trying to follow along and keep up with this but this statement confuses me... how do you designate that a string is utf8 if you don't use that type?

Exactly that is my problem too.
There is a string type UTF8String (provided by Free Pascal)
but we cannot use it with routines like UTF8Delete (which
was designed to work on UTF8 strings only).
This is hard to understand.

I want to make my code readable and therefore I use(d)
UTF8String types in all my programs and now I have to
move back to the chimera STRING and somehow make
sure with crude system settings that its codepage is UTF-8
while UTF8String already *is* UTF-8.
That's confusing.

And I have read the "wiki"(s)
  (there are so many and some are still refering to the older versions of FPC)
but I don't get it:

Is it correct that now every ansistring has a static code page
and a dynamic code page (as mentioned in
http://wiki.freepascal.org/FPC_Unicode_support)?

Is it correct that each ansistring type can store strings with any
encoding (dynamic code page) but there is a "genuine" (static) code
page which is preferred (in cases a target encoding needs to be chosen)?

What is the difference between

UTF8String = type ansistring(cp_UTF8);

and

String = type ansistring(cp_ACP);
when cp_ACP=cp_UTF8?

Both would have the same static code page (UTF-8) but may contain
a different encoding at run time. So why can't I use an UTF8String
in the same way as a String type as parameter?
Why are they not assignment compatible?





More information about the Lazarus mailing list