I have a weird issue for several years now. Here's the thing.
I run Rocky Linux (happens also in CentOS), running Apache 2.4.53 wiith MariaDB (mysql Ver 8.0.30 for Linux on x86_64 (Source distribution)
I have a Tcl script which executes a "curl" to retrieve data from another site. It comes in JSON format which I then parse (using the JSON package). I then insert data into a database, such as:
insert into table set name='Mário Flores';
As you can see there is an UTF-8 character (á). I have the database in utf8mb4 charset, everything is correctly set, the locale in the system is "en_US.UTF-8".
Now... if I have the script run in my Linux box, there are no issues. If I use my website, I click on a button which does a POST to my webserver (index.cgi) and I get an error:
Error: mysqlexec/db server: Incorrect string value: '\xE1rio...' for column 'name' at row 1
and that will then run the "curl" to get the data, parse the JSON and insert into the database. The code is the same, called the same way.
What could be the issue here? I can only solve the problem if, when run by web I do:
set name [encoding convertto utf-8 $name]
And then insert into the DB.
Tried both in Linux or via web, with different results. Expected everything being already UTF-8 compatible and no conversion needed