MYSQL-土耳其语字符 [英] MYSQL - Turkish character

查看:74
本文介绍了MYSQL-土耳其语字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从mysql检索数据

I retrieve datas from mysql

这通常是我在数据库中的

This is normally which i have in db

这通常是我在数据库中

Seçimler, Şirketler ve Siyasi Partiler

它打印

Se�imler, ?irketler ve Siyasi Partiler

我使用sql yog并更改数据库中的某些首选项

I use sql yog and change some preferences in my db

我将字符集设置为UTF8,而归类为utf8_turkish_ci

i set Charset to UTF8 and Collation is utf8_turkish_ci

但仍会像这样检索数据

Se�imler, ?irketler ve Siyasi Partiler

为什么?有什么问题 ?

why? What's the problem ?

推荐答案

这个问题听起来像是您错过了在某处指定字符编码的问题.要解决此问题,只需确保将字符编码设置为 utf-8每个人(实际上并不需要是utf-8,只需在各处使用相同-但是,如果您弄乱了某些东西并且无论如何都需要更改一些地方,我强烈建议您使用utf-8):

this problem sounds like you've missed to specify a character encoding somewhere. to solve this, simply make sure you've set character encoding to utf-8 everywere (it doesn't actually need to be utf-8, just the same everywhere - but if you've messed up something and need to change some places anyway, i'd strongly recommend using utf-8):

  • 告诉MySQL使用utf-8.为此,请将其添加到您的my.cnf中:

  • tell MySQL to use utf-8. to do this, add this to your my.cnf:

collation_server = utf8_unicode_ci
character_set_server = utf8

  • 在与mysql进行交互之前,请发送以下两个查询:

  • before interacting with mysql, send this two querys:

    SET NAMES 'utf8';
    CHARSET 'utf8';
    

    或者,或者,让php在打开连接后执行以下操作:

    or, alternatively, let php do this afteropening the connection:

    mysql_set_charset('utf8', $conn);
    

  • 将UTF-8设置为数据库的默认字符集

  • set UTF-8 as the default charset for your database

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

  • 对表执行相同操作

  • do the same for tables:

    CREATE TABLE `my_table` (
      -- ...
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
    

  • 假定客户端是浏览器,将您的内容作为utf-8和正确的标头提供:

  • assuming the client is a browser, serve your content as utf-8 and the the correct header:

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

    要真正确保浏览器能够理解,请添加一个元标记:

    to be really sure the browser understands, add a meta-tag:

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

  • ,最后但并非最不重要的一点是,告诉浏览器使用utf-8提交表单

  • and, last but not least, tell the browser to submit forms using utf-8

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

  • 这篇关于MYSQL-土耳其语字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆