You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

mercure08

Trainee

  • "mercure08" is male
  • "mercure08" started this thread

Posts: 62

Location: Tunisia

  • Send private message

1

Wednesday, February 4th 2009, 7:53am

Problem migrate frensh characters from Interbase to Mysql

Hello everybody, I've written a Qt program which migrate data from an Interbase database to a MySQL database.
It works fine but I've a problem with frensh characters like (é, è, à, etc).
Those charcaters are fine in the interbase database, but after executing the select request to have data and I display the data I've selected those characters are displayed as " ? ".
This my connection function

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
QSqlDatabase db = QSqlDatabase::addDatabase(driver, name);
db.setHostName(host);
db.setDatabaseName(path);
db.setUserName(user);
db.setPassword(pwd);
if(driver == "IBASE")
db.setConnectOptions("ISC_DPB_LC_CTYPE = LATIN1");

if(!db.open())
{
qCritical() << "Erreur Ouverture base de données : " << db.lastError().text();
return false;
}
return true;
.
Can anyone tel me where I'm wrong and how to do resolve this problem.
Knowing that I've tried to user QTextCodec like

Source code

1
2
QTextCodec *codec = QTextCodec::codecForName("LATIN1");
qDebug() << codec->toUnicode(q1.value(1).toByteArray());
but I've always the same result " ? ".
Many thanks in advance.
Best Regurads.

2

Wednesday, February 4th 2009, 8:32am

RE: Problem migrate frensh characters from Interbase to Mysql


Source code

1
2
QTextCodec * codec = QTextCodec::codecForName( "LATIN1" );
qDebug() << codec->toUnicode( q1.value( 1 ).toByteArray() );


do you display
data read from the Interbase database
or data read from the MySQL database
after the migration?

in the second case
try to create mysql database/tables with
DEFAULT CHARSET=latin1
statment

This post has been edited 1 times, last edit by "Nicolas SOUCHON" (Feb 4th 2009, 8:37am)


mercure08

Trainee

  • "mercure08" is male
  • "mercure08" started this thread

Posts: 62

Location: Tunisia

  • Send private message

3

Wednesday, February 4th 2009, 8:37am

Thank you for your intresting to my problem.
The data displayed are from the Interbase database before the migration. I display them just after I execute the SELECT query.

4

Wednesday, February 4th 2009, 8:40am

I don't know Interbase
but there should be a query
to know how the database/tables were created
try it and show result

mercure08

Trainee

  • "mercure08" is male
  • "mercure08" started this thread

Posts: 62

Location: Tunisia

  • Send private message

5

Wednesday, February 4th 2009, 10:09am

Here is the shema of the table :

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
CREATE TABLE AD (
	TITRE            	VARCHAR(2) CHARACTER SET NONE,
	NOM              	VARCHAR(20) CHARACTER SET ISO8859_1,
	NOMJF            	VARCHAR(20) CHARACTER SET NONE,
	PRE              	VARCHAR(20) CHARACTER SET NONE,
	DEP              	VARCHAR(2) CHARACTER SET NONE,
	SITU             	VARCHAR(1) CHARACTER SET NONE,
	ANN              	DOUBLE PRECISION,
	NAT              	VARCHAR(3) CHARACTER SET NONE,
	PRO              	VARCHAR(100) CHARACTER SET NONE,
	RUE              	VARCHAR(31) CHARACTER SET NONE,
	AD_ID            	INTEGER NOT NULL,
);

As you see, the charset is NONE, I've changed the 2nd column to ISO but I've always the same result.

6

Wednesday, February 4th 2009, 3:02pm

in mysql, you can use
SHOW CREATE DATABASE database;
SHOW CREATE TABLE table;
to obtain the complete statment to use
to create a new database / table
on any installation
independently of default settings

eg:
mysql> create table test (x integer not null);
Query OK, 0 rows affected (0.08 sec)

mysql> show create table test;
+-------+-------------------------------------------------------------------------------------+
| Table | Create Table |
+-------+-------------------------------------------------------------------------------------+
| test | CREATE TABLE `test` (
`x` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+-------+-------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>
[code]
try to find equivalent (perhaps the same)