简体   繁体   English

MySQL和PHP中的全局语言

[英]Global languages in MySQL with PHP

We started website in intention that we only use English language and do all insertion/deletion to MySQL using English. 我们启动网站的目的是仅使用英语,并使用英语对MySQL进行所有插入/删除操作。 And use PHP to escape string while writing to database. 并使用PHP在写入数据库时​​转义字符串。

Now the situation is our website have lot of Chinese/German/Russian users, and we are facing problem writing data into MySQL - PHP is able to write data to the database but it does some internal conversions like it replace a few characters to something different (eg. Plötzlich --> Plq$tzlich). 现在的情况是,我们的网站上有很多中文/德文/俄文用户,我们面临将数据写入MySQL的问题-PHP能够将数据写入数据库,但它会进行一些内部转换,例如将一些字符替换为其他字符(例如Plötzlich-> Plq $ tzlich)。

But if I go to phpMyAdmin and copy paste Chinese or any other language string and do insert it write exactly as it is. 但是,如果我转到phpMyAdmin并复制粘贴中文或任何其他语言的字符串,然后将其插入并按原样编写。 So suspecting is that PHP doing conversion before writing to the database. 因此令人怀疑的是,PHP在写入数据库之前进行了转换。

We are in process to make it work for all language, but this is first time we are dealing with global languages in (MySQL and PHP). 我们正在努力使其适用于所有语言,但这是我们第一次使用(MySQL和PHP)处理全局语言。

If any expert could share some info that would be great and highly appreciated. 如果有任何专家可以分享一些信息,那将是很棒的,并受到高度赞赏。

  1. We have MYSQL InnoDB database with data in it, how shall we do conversion to support global languages? 我们有包含数据的MYSQL InnoDB数据库,如何进行转换以支持全局语言?
  2. We use PHP to write records to MySQL and use escape string (data) and then write it to database. 我们使用PHP将记录写入MySQL,并使用转义字符串(数据),然后将其写入数据库。 We think that escape does not support global languages it does some conversion. 我们认为转义不支持全局语言,它会进行一些转换。 How to handle this or what else we should use? 如何处理此问题或我们还应该使用什么?
  3. Does this conversion impact existing data in database? 这种转换会影响数据库中的现有数据吗?

We would be really thankful if we get some expert help on this. 如果我们在这方面得到一些专家帮助,我们将非常感谢。

I would make sure your app is all in UTF-8, including all the db tables. 我将确保您的应用程序全部位于UTF-8中,包括所有数据库表。 Sounds like some part is not UTF-8. 听起来有些部分不是UTF-8。

Who do you escape your text? 您向谁转义? Maybe something like 也许像
http://www.w3schools.com/php/func_string_htmlentities.asp http://www.w3schools.com/php/func_string_htmlentities.asp
could help? 有帮助? Where all characters are escaped into html entities. 所有字符都转义为html实体。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM