We have a php page inserting into mysql db. The problem all the tables in mysql we have been just using the default collation and character set as the latin1_swedish_ci. All have been working well where I can insert russian character and view it well. But I notice in the db is stored in this format the russian characters e.g ДоÑтавка груза. The issue now we also have java based backend system which reads from the db and read as this only ДоÑтавка груза ? So what is the resolution to this problem. I know is encoding issue.

Member Avatar for LastMitch

@newbie14

The issue now we also have java based backend system which reads from the db and read as this only ДоÑтавка груза ? So what is the resolution to this problem. I know is encoding issue

You can used:

mysql_set_charset ('utf8', $ this-> db);

or this:

mysql_query( "set names 'utf8'" ) ;

Then you need to modify mysql config(my.cnf)

[client]
default-character-set=utf8

[mysqld]
default-character-set=utf8

fixed that issue

lastmitch I have tried your option but is the same when I run my java app what I see on the terminal is still see something like this e.g.ДоÑтавка груза

Member Avatar for diafol

Can't you change the charset/collation of the db/table directly? This would probably be the best way methinks. latin1_swedish_ci is all well and good, but as you've noticed, some chars get messed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.