Warning message:
Warning: Implicit string type conversion with potential data loss from "WideString" to "AnsiString"
Is this directive:
{$modeswith unicodestrings}
still present in your unit?
Remove it and try again.
It is now removed. Warning is gone, but problem is not fixed.
Anyway, thank you for clearing the Warning message.
That directive tells to compiler to treat "String" type as UnicodeString (not AnsiString). Except in special cases, you should not use it in LCL applications.
Now, make sure you do not use UTF8String anywhere, as LCL handles UTF8 encodings its own way, so, except in special cases, you should not normally let FPC make any conversions in LCL applicatons, it would lead to double conversions, thus corrupting string's content.
Simply, in general, this should be enough:
- make sure that your source files (units) are saved in utf8 encoding (I am not talking about using any compiler directive, just about how the files are saved).
- declare your string variables as just "String", do not use UTF8String, UnicodeString or any specific code page string.
- do not set any code page directive yourself.