0

my database is in UTF8, but i have foreign words stored in it. such as:

Mörda Dig Själv
Självdestruktivitetens
D'une Mère à Sa Fille

all copy-pasted from Excel

on the website they actually appear ok, but if i look at these records in DB thru MySQL Workbench, they don't look right:

Mörda Dig Själv...
Självdestruktivitetens

i'm not sure whether they are stored correct and MySQL terminal doesn't display them correctly or they aren't stored correctly and Chrome treating them right.

i tried to use Encoding object created by Sebastián Grignoli here, but it doesn't make any difference to DB or Chrome (in particular toUTF8, fixUTF8 and UTF8FixWin1252Chars methods)

how can i ensure that foreign letters treated correctly in DB?

update:

i have exported all data from DB to csv, and letters don't look correct:

Mörda Dig Själv...
Självdestruktivitetens 
Community
  • 1
  • 1
Elen
  • 2,345
  • 3
  • 24
  • 47
  • 1
    Do you have any idea what the original encoding is? I'm guessing it's just the terminals fault. By the way, the first two lines of foreign text are... interesting.. swedish. It means "murder yourself" and "the self destructiveness", fyi – Dervall Feb 07 '12 at 16:56
  • How did you get this data into your database? – Wooble Feb 07 '12 at 16:58
  • You say "on the website they appear ok" ... but then are worried they are somehow not stored in the DB correctly? How are they getting to the "website" ? – Brian Roach Feb 07 '12 at 16:59
  • @ Dervall - yes they are names of sweedish songs =) - i have no idea of original encoding - this is a pain, but all data comes from excel and to excel it can be anything... – Elen Feb 07 '12 at 17:02
  • @ Brian Roach - they are displayed on website from DB after i inserted them into it as described above. – Elen Feb 07 '12 at 17:03
  • @Elen - then there's your answer. They're stored perfectly fine in the DB and the problem is the *other program you're using* isn't displaying the correct character set. The web browser isn't magic ;) – Brian Roach Feb 07 '12 at 17:08
  • I've never used MySQL Workbench, but try comparing the output of these two queries in MySQL Workbench and in your website code: SHOW VARIABLES LIKE 'character_set%'; SHOW VARIABLES LIKE 'collation%'; – Daan Feb 07 '12 at 17:10
  • i have updated my post - when exported from DB - letters aren't right. – Elen Feb 07 '12 at 17:14
  • I think you're having a hard time understanding how character sets work. When you export them to a CSV, the *other program you're using* (e.g. the terminal) isn't showing them correctly (Or, the export isn't done in the right character set). You've already demonstrated that they are in the database correctly. – Brian Roach Feb 07 '12 at 17:47
  • @ Brian Roach - but i imported it from CSV =) so what has changed? but let me try again tomorrow all import-export procedure to make sure – Elen Feb 07 '12 at 17:50
  • In Workbench, click on the table and select 'Alter Table ...', then check the top row for the collation of the `VARCHAR` column I assume you're using to store the names. – Naltharial Feb 08 '12 at 08:03
  • @ Naltharial - collation is UTF8 – Elen Feb 08 '12 at 10:18
  • i used PHPExcel to export data - and it looks all fine. thanks everyone – Elen Feb 08 '12 at 16:31

0 Answers0