I'm trying to assign the Tricolon Unicode character #$205D as the caption to a button in a Lazarus Windows program like this:
MyButton.Caption := #$205D;
It works, the button displays the Tricolon fine, but the compiler emits the warning "Warning: Unicode constant cast with potential data loss".
How do I correctly assign the Tricolon character to the caption of an LCL control to get rid of the warning?
LCL uses UTF8 encoding but #$205D is UTF16 character constant. So use UTF8 encoded constants instead:
const
CTricolon = #$E2#$81#$9D;
//CTricolon = '⁝'; // Also works fine if using character(s) as is in the source
...
MyButton.Caption := CTricolon;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With