Hi,
i've got some problems with my program, when compiling and using the program on MAC. under windows and linux it works without problems.
the program uses a mysql database for displaying and storing data. qsql* classes are used for all the mysql stuff.
now the problem is, there is one input field, a qtextedit, which can be saved to the database when the user clicks the save button. the saving is done via sqlquery("update ..."). on linux+windows this works without problems. on MAC, however, i encounter problems as soon as there is any special characters (like öäü) in the text. the text will be saved to the database, but it will be cut off at the position of the first special character.
so, when you enter a text like "this is my ä text", the program will save "this is my " in the database. you can do the same on linux and windows, there the program will save "this is my ä text" correctly.
for this specific input field i already found a solution. when executing the sql query with qtextedit->text() as parameter, i added a ->toUft8(), so the qtextedit contents will be converted to utf8 before saving to database. this way you can again save special characters on MAC too.
but, since the programs main display is a QSqlRelationalTableModel + qtableview, i still have the same problems. records will be saved with the model->submitAll() method, and there is no way of implementing ->toUtf8(). so again, when someone inputs special characters in the tableview, they wont be saved.
in addition to this, special characters that are already saved in the database, will be selected and displayed correctly even on MAC. so when you save records with äöü on windows, you can see them correctly in the tableview on mac.
on the database side all characterset properties are set to utf8. " .. $> locale" on MAC shows utf8 encoding. in the code of the program i even set
|
Source code
|
1
2
|
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
|
when i exec the query "show variables" on MAC from within the program, i get these results:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
+---------------------------------+--------------------------------------------------------------+
| Variable_name | Value |
+---------------------------------+--------------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| collation_connection | utf8_general_ci |
| collation_database | utf8_general_ci |
| collation_server | utf8_general_ci |
|
so, everything seems to be set to utf8. so whats wrong then? can someone help me please?