Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I prevent the warning "unicode constant cast with potential data loss" in Lazarus?

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?

like image 540
dummzeuch Avatar asked Feb 01 '26 21:02

dummzeuch


1 Answers

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;
like image 151
Abelisto Avatar answered Feb 03 '26 12:02

Abelisto



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!