utf-8 chars conversion when store data
| User, date | Message |
|---|---|
|
Written by mathiand
9 months ago Category: Feature discussion 6 posts since Sat, 25 Aug 12 |
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? |
|
Written by ansgar
9 months ago 3977 posts since Fri, 07 Apr 06 |
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. |
|
Written by mathiand
9 months ago 6 posts since Sat, 25 Aug 12 |
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; |
|
Written by mathiand
9 months ago 6 posts since Sat, 25 Aug 12 |
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. |
|
Written by ansgar
9 months ago 3977 posts since Fri, 07 Apr 06 |
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. |
|
Written by ansgar
9 months ago 3977 posts since Fri, 07 Apr 06 |
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. |
|
Written by mathiand
9 months ago 6 posts since Sat, 25 Aug 12 |
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? |
|
Written by ansgar
9 months ago 3977 posts since Fri, 07 Apr 06 |
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! |
|
Written by ansgar
9 months ago 3977 posts since Fri, 07 Apr 06 |
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'. |
|
Written by mathiand
9 months ago 6 posts since Sat, 25 Aug 12 |
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!!! |
|
Written by jfalch
9 months ago 224 posts since Sat, 17 Oct 09 |
the problem was probably not character_set_server but character_set_client, which is also changed by SET NAMES. |
|
Written by mathiand
9 months ago 6 posts since Sat, 25 Aug 12 |
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. |