[Lazarus] Improving UTF8CharacterLength?

Michael Van Canneyt michael at freepascal.org
Thu Aug 13 12:59:51 CEST 2015



On Thu, 13 Aug 2015, Jürgen Hestermann wrote:

> Am 2015-08-13 um 11:55 schrieb Mattias Gaertner:
>
>> If you know that you have a valid UTF-8 string you can simply use the
>> first byte of each codepoint (as you pointed out). So, for that case a
>> faster function can be added.
>> Maybe UTF8QuickCharLen or something like that.
>
> Determining the character length of a invalid UTF-8 string is quite useless.

Because it's not about getting a correct result then, but about not crashing due to invalid memory access.

Many safety leaks are due to invalid memory access.

Michael.


More information about the Lazarus mailing list