set fileencoding=utf8 ;
修改vim文件编码。
切忌不是fileencodings
文件fileencoding也会影响输出编码形式
1,html中的编码:如a.htm
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
告诉浏览器使用什么编码来解析返回的内容;
其中a.htm文件本身的编码也要注意,如果a.htm文件的编码与charset的编码不一致中文也会乱码。
2,cgi中:如get.php
header("Content-Type: text/html; charset=GB2312");
以什么编码返回数据类容。
3,数据库字符集编码
set names'latin1';
此设置相当于执行下面三个设置。
SET character_set_client = utf8;
SET character_set_results = utf8;
SET character_set_connection = utf8;
看看这3个变量的作用:
信息输入路径:client→connection→server;
信息输出路径:server→connection→results。
换句话说,每个路径要经过3次改变字符集编码。以出现乱码的输出为例,server里utf8的数据,传入connection转为latin1,传入results转为latin1,utf-8页面又把results转过来。如果两种字符集不兼容,比如latin1和utf8,转化过程就为不可逆的,破坏性的。
4,创建库表,甚至字段时可以指定编码。
附:
set fileencoding=utf8 ;
修改vim文件编码。
切忌不是fileencodings
文件fileencoding也会影响输出编码形式