SelLength and SelText return incorrect values when there are codepoints outside Unicode BMP
Original Reporter info from Mantis: fedkad
-
Reporter name: Fedon Kadifeli
Original Reporter info from Mantis: fedkad
- Reporter name: Fedon Kadifeli
Description:
For TEdit or TMemo (and maybe other controls) the SelLength property returns wrong information for selections containing codepoints with codes larger than $FFFF.
Environment: Windows 7 + Lazarus 1.6.4 (64 bit).
Steps to reproduce:
For example, create a TMemo or TEdit object and during run time paste the character 𝛁 (code: $1D6C1 = 'MATHEMATICAL BOLD NABLA') to it; then do a select all (Ctrl+A) and run the code:
showmessage( inttostr(utf8length(Memo1.Text))
+ ' ' + inttostr(Memo1.SelLength)
+ ' ' + inttostr(utf8length(Memo1.SelText))
);
It will display 1 2 1.
Strangely enough, if you add
Memo1.SelectAll;
before the code above, it will display 1 1 1.
Additional information:
Please, run the code attached in a Windows + Lazarus (1.6.4) environment and try to select from the beginning of the Editbox 1, 2, and 3 characters. The relevant values will be displayed on the right.
I tested the same code in Linux + Lazarus (1.8.0~rc4) and it did not have the problem described above.
Forum post: http://forum.lazarus.freepascal.org/index.php/topic,39045.0.html
Mantis conversion info:
- Mantis ID: 32731
- OS: Windows
- OS Build: 7 (64-bit)
- Build: x86_64-win64-win32/win64
- Platform: x86_64
- Version: 1.6.4
- Monitored by: » fedkad (Fedon Kadifeli)