Turkish character encoding using MySQL

I have problems with Turkish characters, as I mentioned in the title. I created a MySQL function:

DELIMITER $$ CREATE DEFINER=`root`@`localhost` FUNCTION `ilgiAlaniFunc`( idKullanici INT, ilgi_alani_ismi varchar(255) CHARSET utf8 COLLATE utf8_turkish_ci ) RETURNS varchar(255) CHARSET utf8 COLLATE utf8_turkish_ci READS SQL DATA DETERMINISTIC BEGIN -- Function logic here DECLARE ret int DEFAULT -1; select id Into ret from ilgi_alanlari where ilgi_alani_adi=ilgi_alani_ismi limit 1; IF(ret = -1) then INSERT INTO ilgi_alanlari(ilgi_alani_adi) values (ilgi_alani_ismi); SELECT last_insert_id() into ret; END IF; insert into kullanici_ilgi_alani(kullanici_id, ilgi_alani_id) values (idKullanici, ret); RETURN ret; END 

This is a dump of the queries I run:

 111 Connect root@localhost on anketsis_main 111 Query select ilgiAlaniFunc(43,'kıvılcım') 111 Query select id Into ret from ilgi_alanlari where ilgi_alani_adi= NAME_CONST('ilgi_alani_ismi',_utf8'k' COLLATE 'utf8_turkish_ci') limit 1 111 Query insert into kullanici_ilgi_alani(kullanici_id, ilgi_alani_id) values ( NAME_CONST('idKullanici',43), NAME_CONST('ret',54)) 

Here you can see that 'kıvılcım' turns into 'k'. After the first Turkish character, MySQL then erases everything.

And here is the correct dump:

 120 Query select ilgiAlaniFunc(44,'Hello') 120 Query select id Into ret from ilgi_alanlari where ilgi_alani_adi= NAME_CONST('ilgi_alani_ismi',_utf8'Hello' COLLATE 'utf8_turkish_ci') limit 1 120 Query INSERT INTO ilgi_alanlari(ilgi_alani_adi) values ( NAME_CONST('ilgi_alani_ismi',_utf8'Hello' COLLATE 'utf8_turkish_ci')) 120 Query SELECT last_insert_id() into ret 120 Query insert into kullanici_ilgi_alani(kullanici_id, ilgi_alani_id) values ( NAME_CONST('idKullanici',44), NAME_CONST('ret',56)) 

As you can see, “Hello” is “Hello” everywhere.

Each sort is utf8_turkish_ci in my schema. Edit: I noticed that my question does not include the question. So here it is: how can I get MySQL to believe that I'm sending more rows than I think

+2
source share
2 answers

I assume that you are sending these requests with PHP. I can say that because you are me.

Apparently, sorting "utf8_turkish_ci" can decode utf8 gibberish codes, but not simple Turkish characters. Changing encodings in php files to header('Content-Type: text/html; charset=utf8'); allows you to solve this problem.

+3
source

I, I used the notepad ++ text editor and had the same problem. (despite the top solution) On the encoding tab there is a choice as a code with UTF-8, I selected it and saved the file. After I sent the code to the server, it works :)

0
source

All Articles