[Lazarus] Improving UTF8CharacterLength?

Mattias Gaertner nc-gaertnma at netcologne.de
Fri Aug 14 11:12:41 CEST 2015


On Thu, 13 Aug 2015 14:53:50 +0200
Jürgen Hestermann <juergen.hestermann at gmx.de> wrote:

>[...]
> If I am right (after a quick look) then UTF8CharacterStrictLength gives back 0
> in cases where UTF8CharacterLength would give back 1.

Yes.

 
> IMO this does not change the underlying problem that if you have an invalid UTF-8
> string then you cannot fix this situation within functions like UTF8CharacterLength
> or UTF8CharacterStrictLength.

They should not fix it. If you want to fix a string you can use the UTF8FixBroken
function.

> There is no way around it other than:
> 
> 1.) Make sure your strings are all valid UTF-8 or
> 2.) Do error checking and error handling in your program yourself

3.) Skip invalid chars.

Mattias




More information about the Lazarus mailing list