将UTF8数据方便地输入到MySQL [英] Input UTF8 data conveniently to MySQL

查看:77
本文介绍了将UTF8数据方便地输入到MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我来自匈牙利,如果谈论字符编码,事情会变得很复杂.当我编写网站代码时,我无法避免将简单的数据存储在MySQL中,这通常不需要管理员界面即可处理.我的意思是我不会让管理员在表中记录菜单名称.但是我必须.由于不可能(或者我还没有找到解决方案)在phpMyadmin中记录UTF8属性. 通过phpMyadmin发送输入内容时,我的输入在UTF8字段中始终保持ISO-8859-2编码.如果我使用UTF8网页,UTF8表单,所有UTF格式将数据发送到数据库,则我完全没有问题

I'm from Hungary which makes things complicated if talking about character encoding. When I code websites I cannot avoid storing simple data in MySQL which normally would not require an admin surface to handle. I mean I would not make an admin for recording menu names in a table. But I have to. Since it's impossible (or I haven't found a solution yet) to record UTF8 attributes in phpMyadmin. My input stays ISO-8859-2 encoded in the UTF8 field as I send it via phpMyadmin. If I send data to the database using an UTF8 webpage, UTF8 form, everything UTF, I have absolutely no problem.

所以我的意思是,每次我想将一些UTF8插入到UTF8编码的数据库中时,制作管理员界面或类似的东西都是很费时间的. phpmyadmin对我来说不可用.但是我不想自己编写另一个phpmyadmin.这是没有道理的.必须有一个解决方案.你能帮忙吗?

So my point is that it's circumstantial and time-consuming to make an admin surface or something like that every time I want to insert some UTF8 to an UTF8 encoded database. phpmyadmin is unusable for me. But I don't feel like programming another phpmyadmin on my own. It would make no sense. There must be a solution. Can you help?

(实际的UTF8属性显示正确的方式.标有蓝线的行已用phpmyadmin记录,未存储为UTF8.)

(Actual UTF8 attributes show off the right way. The line marked with blue line has been recorded with phpmyadmin and is not stored as UTF8.)

推荐答案

我只是将一个非常狂野的刺入黑暗之中:

I'll just take a very wild stab into the dark:

phpMyAdmin实际上是正确的.无效的界面是您的自定义界面,因为它没有正确设置连接编码.因此,您通过它插入的所有数据都被数据库弄乱了,但是恰好在您的应用程序中进行了一次干净的往返. phpMyAdmin插入 actual UTF-8数据,当通过错误的连接进行检索时,该数据会混乱.

phpMyAdmin actually gets it right. The one that isn't working is your custom interface, because it's not setting the connection encoding correctly. So all the data you insert via it is messed up in the database but happens to have a clean roundtrip in your application. phpMyAdmin inserts actual UTF-8 data, which messes up when retrieved via your wrong connection.

请始终参见 UTF-8 在Web应用程序中处理Unicode从头到尾.

这篇关于将UTF8数据方便地输入到MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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