Forum > Unix

UTF-8 and Laz 2.0.10/fpc 3.2.0 Chinese characters

(1/2) > >>

OH1KH:
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.

Fred vS:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---~> 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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Edit1.font.name := 'unifont';
I hope it helps.

Fre;D

OH1KH:
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.

OH1KH:
In addition to mysql error:

--- Code: Bash  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---MariaDB [cqrlog007]> show columns from cqrlog_main;+----------------+---------------+------+-----+---------+----------------+| Field          | Type          | Null | Key | Default | Extra          |+----------------+---------------+------+-----+---------+----------------+  | state          | varchar(4)    | YES  |     |         |                |

dbannon:
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

Navigation

[0] Message Index

[#] Next page

Go to full version