Recent

Author Topic: UTF8 and numeric to string conversion  (Read 6048 times)

ASerge

  • Hero Member
  • *****
  • Posts: 2223
Re: UTF8 and numeric to string conversion
« Reply #15 on: January 15, 2018, 12:50:10 am »
The example from @wp works for you?

Lutz Mändle

  • Jr. Member
  • **
  • Posts: 65
Re: UTF8 and numeric to string conversion
« Reply #16 on: January 15, 2018, 01:03:04 am »
Ok, then it should work, I've set up a small testproject with only one form with a TLabel and this FormCreate procedure:

Code: Pascal  [Select][+][-]
  1. procedure TMainForm.FormCreate(Sender: TObject);
  2. var
  3.   fAngle:double;
  4.   sAngle,
  5.   sCenterLabel:string;
  6.  
  7. begin
  8.   fAngle:=23.3;
  9.   sAngle:=FloatToStr(fAngle);
  10.   sCenterLabel:=sAngle+'°';
  11.   Label1.Caption:=sCenterLabel;
  12. end;
  13.  

If the source file ist utf8 encoded (with or without bom) it works correct in Windows (win32 widgetset) and Linux (qt5 widgetset).

Maybe some special things in Project->Project Options->Compiler Options->Additions and Override. I have no special settings here only LCLWidgetType is defined.
« Last Edit: January 15, 2018, 01:11:28 am by Lutz Mändle »

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: UTF8 and numeric to string conversion
« Reply #17 on: January 15, 2018, 09:12:18 am »
What is the encoding of the source file? Check it with right clicking in the source editor, then choose Filesettings->Encoding (Dateieinstellungen->Zeichenkodierung) in the popup menu.
Not sure if this is the real encoding of the file or just what it should be. Better to go the safe way: Open the source file which causes the trouble in a hex editor. Find the position with the '°'. Is there one byte ($B0) or two ($C2 $B0)? If its one byte then the file is ANSI. See attached screenshots taken from my demo above: "deg_utf8.png" is the original source file, "deg_ansi.png" after conversion to ansi.
« Last Edit: January 15, 2018, 09:35:31 am by wp »

Lutz Mändle

  • Jr. Member
  • **
  • Posts: 65
Re: UTF8 and numeric to string conversion
« Reply #18 on: January 15, 2018, 09:21:31 am »
I have checked this too, Lazarus indeed changes the real file encoding if you click in the Change Encoding dialog the button Change file.

 

TinyPortal © 2005-2018