将字符转换为多字节等效字符

将字符转换为多字节等效字符

本文介绍了Mysql:latin1-> UTF8。将字符转换为多字节等效字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

latin1 中有一个表格, cp1252
中的网站我想在 utf8 中的表格和 utf-8

There was a table in latin1 and site in cp1252I want to have table in utf8 and site in utf-8

我已经完成了:

1)在网页上: code>内容类型:text / html; charset = utf-8

1) on web page: Content-Type: text/html;charset=utf-8

2)Mysql: ALTER TABLE XXX转换为CHARACTER SET utf8

_

SQL不工作,因为我想要 - 它不会转换ä&数据库中的ü字符以其多字节等价物

This SQL doesn't work as I want - it doesn't convert ä & ü characters in database to their multibyte equivalents

请帮助。
坦克

Please Help.Tanks

推荐答案

我一直是个傻瓜。

1)每个时间字符集的列被改变,实际的数据是ALWAYS重新编码!将字段更改为二进制查看。

1) Every time the charset of a column is changed, the actual data is ALWAYS recoded! Change field to binary to see that.

2)列的字符集先于!,表和db charset的优先级遵循。它们主要用于设置默认值。 (不是100%肯定最后一句话)

2) The charset of a column is prior!, the table and db charset follow in the priority. They are used mainly for setting defaults. (not 100% sure about last sentence)

3) SET NAMES 非常重要。德语字符可以进入latin1,并正确放置在utf8表中(由Mysql默认重新编码),当您正确设置NAMES。服务器可以将您所需编码的数据发送到网页,无论表编码为何。它可以被重新编码为输出

3) SET NAMES is very important. German characters can come in latin1 and be placed get correctly in utf8 table(recoded by Mysql silently) when you SET NAMES correctly. The server can send data to a web page in the encoding you desire, no matter what the table encoding is. It can be recoded for output

4)如果编码A和编码B中的列有一列,并且比较它们(或使用LIKE),则Mysql将默认转换它们,使它看起来像一个编码

4) If there is a column in encoding A and a column in encoding B, and you compare them (or use LIKE), the Mysql will silently convert them so that it looks like they are in one encoding

5)Mysql是聪明的。它不会像文本一样使用字节,除非类型为二进制。它总是作为人物运作!他希望如果他知道数据编码

5) Mysql is smart. It never operates with text as with bytes unless the type is binary. It always operates as characters! He wants that ё in latin1 would equal ё in utf8 if he knows the data encoding

这篇关于Mysql:latin1-> UTF8。将字符转换为多字节等效字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 13:27