On 2022-03-24 20:47, Santi via fpc-pascal wrote:
El 23/03/2022 a las 10:51, Mattias Gaertner via fpc-pascal escribió:

FPC does not yet understand comments,
What do you mean with "understand comments"?

Mattias meant that comments were the only place where information about use of CP1252 was included.


so maybe it does not know this
literal is cp1252. Add {$codepage cp1252} somewhere at the start of
the unit.

If this is part of a Lazarus application, then String is by
default UTF-8, so your "original" is already converted to UTF-8.
So, as far as Ive understood,  without {$codepage cp1252}, when I read
the string from a file, it supposes it is utf8, even when it is not a
valid utf8 string.

First, there are many cases when a file may be a valid UTF-8 file, yet it is still a valid file in ANSI encoding. There must be some default. Lazarus uses UTF-8 as the default.


And ansiToUtf8 doesn't suppose that the input string ansi, but utf8? I
can't understand what is ansiToUtf8  for.

A particular encoding must be already defined when the string is assigned to the string. The string contents may not change depending on which function is called on it (moreover, implicit conversions migt be used regardless from the original encoding.

Tomas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to