Recent

Author Topic: Error: Unknown label identifier @FPC_ANSISTR_SETLENGTH  (Read 1430 times)

PascalDragon

  • Hero Member
  • *****
  • Posts: 2107
  • Compiler Developer
Re: Error: Unknown label identifier @FPC_ANSISTR_SETLENGTH
« Reply #15 on: July 28, 2020, 09:08:49 am »
There is nothing arbitrary about this. The code page aware AnsiString type was the big feature (and change) in FPC 3.0.0 (see here which also references this). The FPC RTL itself initializes with the code page of the operating system, but Lazarus forces this to be UTF-8 (see here), thus why you don't have any problem with a command line application, but see this issue with a LCL GUI application.

To better explain where your problem is:

Code: Pascal  [Select][+][-]
  1. s:='('+#176+')';
  2. Result:=Copy(s, 2, 1)=#176;

The string constant at the right side of the assignment to s is in your system's code page. Due to the LCL's setting of using UTF-8 by default the assignment will convert the string to UTF-8 (you can see this by using Length(s), it will return a value > 3). Thus the following Copy will extract only a part of the UTF-8 character for #176, thus the comparison will fail.

When implementing a new feature, it should be introduced as an extra option beside the well-known old one, not by replacing it!
I still don't understand, why they blatantly REPLACING something with a totally different incompatible thing, messing up existing codes.  :o

There was no way to implement this optionally. The code page aware string is a base part of the language and the way the LCL simply stuffed UTF-8 characters into AnsiStrings was simply wrong now due to the compiler now automatically inserting conversions between code pages thus leading to corruption of the string data.
Also even if we had made this optional, the new behaviour would have been the default anyway and would you have found out that you'd need to change some hypothetical switch? Considering that you didn't know about the string related changes I assume you would not have. So what use would it have been anyway?

winni

  • Hero Member
  • *****
  • Posts: 1782
Re: Error: Unknown label identifier @FPC_ANSISTR_SETLENGTH
« Reply #16 on: July 28, 2020, 10:43:45 am »

When implementing a new feature, it should be introduced as an extra option beside the well-known old one, not by replacing it!
I still don't understand, why they blatantly REPLACING something with a totally different incompatible thing, messing up existing codes.  :o

Wellcome to the new millenium!
Wellcome to Unicode!

Both are now 20 years old. Unicode even older!

Toto - we are not at DOS anymore!

Winni

tetrastes

  • Jr. Member
  • **
  • Posts: 60
Re: Error: Unknown label identifier @FPC_ANSISTR_SETLENGTH
« Reply #17 on: July 28, 2020, 12:13:58 pm »
There was no way to implement this optionally. The code page aware string is a base part of the language and the way the LCL simply stuffed UTF-8 characters into AnsiStrings was simply wrong now due to the compiler now automatically inserting conversions between code pages thus leading to corruption of the string data.
Also even if we had made this optional, the new behaviour would have been the default anyway and would you have found out that you'd need to change some hypothetical switch? Considering that you didn't know about the string related changes I assume you would not have. So what use would it have been anyway?

Moreover, there is such switch: https://wiki.freepascal.org/Lazarus_with_FPC3.0_without_UTF-8_mode .

 

TinyPortal © 2005-2018