MYSQL - Turkish character

I am retrieving data from mysql

It's ok that in my db

This is usually in my db

Seçimler, Şirketler ve Siyasi Partiler

he prints

Se imler, ?irketler ve Siyasi Partiler

I use sql yog and change some settings in my db

i sets Charset to UTF8, and the sorting is utf8_turkish_ci

but still retrieve such data

Se imler, ?irketler ve Siyasi Partiler

why? What is the problem?

+5
source share
3 answers

this problem sounds like you missed to specify a character encoding somewhere. To solve this problem, just make sure that you set utf-8 everywere character encoding (actually it should not be utf-8, the same is everywhere - but if you messed up something and you need to change some places, I highly recommend use utf-8):

  • MySQL utf-8. my.cnf:

    collation_server = utf8_unicode_ci
    character_set_server = utf8
    
  • mysql :

    SET NAMES 'utf8';
    CHARSET 'utf8';
    

    , , php :

    mysql_set_charset('utf8', $conn);
    
  • UTF-8

    CREATE DATABASE `my_db` DEFAULT CHARACTER SET 'utf8';
    
  • :

    CREATE TABLE `my_table` (
      -- ...
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    
  • , , utf-8 :

    header('Content-type: text/html; charset=utf-8');
    

    , , :

    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    
  • , , utf-8

    <form accept-charset="utf-8" ...>
    
+10

Charset to UTF8 .

SET NAMES 'utf8';
CHARSET 'utf8';
+1

It was important for me to add the following lines:

collation_server = utf8_unicode_ci

character_set_server = utf8

to my.ini file (at the end of the document) I tried everything else, but they all failed until I made this change. It really helped. Thanks oezi.

+1
source

All Articles