Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2020-09

Warning: Unicode constant cast with potential data loss

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin

FPC 3.2.0

var
   u,u2 : UTF8String;
begin
   u := #$2267'x';
   u2 := #$2267;  // warning

Assigning a WideString to a Utf8String works without warning.

Assigning a WideChar (2nd line) to a Utf8String causes "Warning: Unicode constant cast with potential data loss"
Apparently it is first converted to a char in the System codepage, and then to string.

Is that intended?

Actually if
  u: AnsiString

then the result is '??' (so data is lost), yet no warning.

Reply by email

Tomas Hajny
to Martin
Martin wrote 18 lines
FPC 3.2.0 var   u,u2 : UTF8String; begin   u := #$2267'x';   u2 := #$2267;  // warning Assigning a WideString to a Utf8String works without warning. Assigning a WideChar (2nd line) to a Utf8String causes "Warning: Unicode constant cast with potential data loss" Apparently it is first converted to a char in the System codepage, and then to string. Is that intended?

FWIW, this looks similar to my observation described in number 2 at the bottom of

Tomas

Reply by email