Recent

Author Topic: UTF-8 and Laz 2.0.10/fpc 3.2.0 Chinese characters  (Read 753 times)

OH1KH

  • Jr. Member
  • **
  • Posts: 56
UTF-8 and Laz 2.0.10/fpc 3.2.0 Chinese characters
« on: March 31, 2022, 07:15:22 pm »
HI!

I have strange things happen when entering some Chinese characters to TEdit.

In program there is Tedit for name. Then name is saved to Mysql database column varchar(30)

It works fine with normal character names. Even with names with scandinavian öäåÖÄÅ (and other special utf8)
But if TEdit content is Chinese it will show out wrong in TEdit when pasted to it, or initiated by pushing hex string to TEdit.Text.
How ever  content pushed to TEdit.Text returns in same hex form out than were pushed in.

Just the display view is wrong.

And there is also something else wrong as when TEdit.Text is pushed to database it causes SQL error.
Q.SQL.Text :=  'insert into main (name) values(QuotedStr(trim(stn_name)))';
  (procedure's stn_name is  TEdit.Text when called)

If the "square" shown in picture's TEdit box is removed then pushing to database goes without errors.

Somehow the 1st Chinese char transfers to "square" in display.
Even when pushing hex in and out of TEdit.Text remains same when same hex is pushed to mysql it fails.

What I am missing here?

There is picture showing how characters show out in editor (Leafpad) and TEdit. sytem is Fedora 35 with LXDE desktop.
--
Saku

Fred vS

  • Hero Member
  • *****
  • Posts: 2602
    • StrumPract is the musicians best friend
Re: UTF-8 and Laz 2.0.10/fpc 3.2.0 Chinese characters
« Reply #1 on: March 31, 2022, 10:02:25 pm »
Hello.

What font.name are you using for Edit1 ?

On Unix, in terminal, you may look for the fonts installed compatible with Chinese ideograms:

Code: Bash  [Select][+][-]
  1. ~> fc-list :lang=zh

And use one of the font names for Edit1.font.name

[EDIT] You may use the "Unifont" font that is installed by default in nearly all Unix distro:
 
Code: Pascal  [Select][+][-]
  1. Edit1.font.name := 'unifont';

I hope it helps.

Fre;D
« Last Edit: March 31, 2022, 10:09:12 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs

OH1KH

  • Jr. Member
  • **
  • Posts: 56
Re: UTF-8 and Laz 2.0.10/fpc 3.2.0 Chinese characters
« Reply #2 on: April 01, 2022, 07:42:54 am »
Hi!
Thanks for suggestion!

How ever it does not make any change. Some Chinese marks are still "squares" in display (note that in web browser and Leafpad text editor they show up different way . Not squares (but I can not tell are they ok because I can not read them, but they "look like").


And also saving to mysql database fails as before.
--
Saku

OH1KH

  • Jr. Member
  • **
  • Posts: 56
Re: UTF-8 and Laz 2.0.10/fpc 3.2.0 Chinese characters
« Reply #3 on: April 01, 2022, 07:51:59 am »
In addition to mysql error:
Code: Bash  [Select][+][-]
  1. MariaDB [cqrlog007]> show columns from cqrlog_main;
  2. +----------------+---------------+------+-----+---------+----------------+
  3. | Field          | Type          | Null | Key | Default | Extra          |
  4. +----------------+---------------+------+-----+---------+----------------+
  5.  
  6.  
  7. | state          | varchar(4)    | YES  |     |         |                |

--
Saku

dbannon

  • Hero Member
  • *****
  • Posts: 2045
    • tomboy-ng, a rewrite of the classic Tomboy
Re: UTF-8 and Laz 2.0.10/fpc 3.2.0 Chinese characters
« Reply #4 on: April 01, 2022, 08:14:44 am »
I suspect you are experiencing this know bug -

https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/38454

If you use another way to enter an "extended char" its works fine.   :(

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

OH1KH

  • Jr. Member
  • **
  • Posts: 56
Re: UTF-8 and Laz 2.0.10/fpc 3.2.0 Chinese characters
« Reply #5 on: April 01, 2022, 04:48:11 pm »
With that difference that picture1 (showing TEdit example) is compiled with GTK2 widgets and picture2 (real program in use) is compiled with QT5 widgets.

That does not fit the linked bug description.
--
Saku

 

TinyPortal © 2005-2018