utf-8 chars conversion when store data

[expired user #6555]'s profile image [expired user #6555] posted 12 years ago in Feature discussion Permalink
When I enter text in a field in the data tab and use national (swedish) chars, like å ä ö, theese are stored as iso-8859-1, even when the collation is set to utf-8.
Is it possible to convert the entered text into correct collation?

ansgar's profile image ansgar posted 12 years ago Permalink
Your table or column in that table has the wrong collation than. Please paste the CREATE TABLE query here so I can tell you what you need to do to fix that. HeidiSQL's connection to the server always runs in utf8 mode.
[expired user #6555]'s profile image [expired user #6555] posted 12 years ago Permalink
CREATE TABLE IF NOT EXISTS `sida` (
`sida_id` int(10) NOT NULL AUTO_INCREMENT,
`code` varchar(50) COLLATE utf8_swedish_ci NOT NULL,
`titel` varchar(50) COLLATE utf8_swedish_ci NOT NULL,
`taborder` int(10) NOT NULL DEFAULT '0',
`enable` int(10) NOT NULL DEFAULT '1',
`updated` datetime NOT NULL,
PRIMARY KEY (`sida_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_swedish_ci;
[expired user #6555]'s profile image [expired user #6555] posted 12 years ago Permalink
If I (in HeidiSQL) enter text, "åäö" (swedish chars) it is stored in DB exactly this way, and its wrong. It chould be in utf-8 (Ã¥ , ä , ö).

With PHP everything is ok.
ansgar's profile image ansgar posted 12 years ago Permalink
You should expect broken chars like å only when you're using the wrong charset. As said, HeidiSQL runs in utf8 mode, therfore utf8 chars are displayed the right way.

Your CREATE TABLE code looks perfect - everything's ok here, so you should not expect broken chars here.
ansgar's profile image ansgar posted 12 years ago Permalink
Ah, and åäö are surely displayable in utf8, probably not in latin1. So, if you have a php website which runs in latin1 you get broken chars. Not so when you run it in utf8 mode.
[expired user #6555]'s profile image [expired user #6555] posted 12 years ago Permalink
My PHP site run in utf-8 and everything is ok, and everything is okay when I store text from php into db.

I _only_ taking about when I write text in fields inside HeidiSQL. I want some feature that "convert" written åäö into utf-8 and store it in db.

Is is possible?

ansgar's profile image ansgar posted 12 years ago Permalink
That's what I was trying to explain - your table and its columns are already utf8 "compatible", and so is HeidiSQL itself. You should never see broken chars like å or similar in that table. If you would see these, some client, PHP or whatever did that with a Latin1 based connection, and your data is broken!
ansgar's profile image ansgar posted 12 years ago Permalink
Does your PHP site fire some "SET NAMES utf8" before writing text into that table? It should definitely, otherwise your connection uses the servers default charset, which is latin1 on a default MySQL installation - see it via SHOW VARIABLES LIKE 'character_set_server'.
[expired user #6555]'s profile image [expired user #6555] posted 12 years ago Permalink
Thank you!!

The SET NAMES make it works.

When I do SHOW VARIABLES the result is:
character_set_server;utf8

I think its right, but not working.

No OK, thank you again!!!



jfalch's profile image jfalch posted 12 years ago Permalink
the problem was probably not character_set_server but character_set_client, which is also changed by SET NAMES.
[expired user #6555]'s profile image [expired user #6555] posted 12 years ago Permalink
character_set_client is sett to utf8 too.

Problem is solved, and I say thank you so much.

Please login to leave a reply, or register at first.