Convert WordPress database from Latin1 to UTF-8
January 12, 2008 5:39 pm | In Tech | 2 Comments | hideSome early WordPress databases use raw Latin1 encoding to represent UTF-8 characters. The following seems to be an O.K. way to convert those databases to native UTF-8 databases (at least it works for me, Mysql 5.0.45):
- Stop/restrict web service.
- Dump the database:
$ mysqldump --default-character-set=latin1 --databases wordpress > m.sql
- Change encoding settings in m.sql, including table default encoding and client communication encoding:
$ replace "CHARSET=latin1" "CHARSET=utf8" \ "SET NAMES latin1" "SET NAMES utf8" < m.sql > m2.sql - Import the “converted” sql:
$ mysql < m2.sql
- Add the following lines to WordPress wp-config.php
define('DB_CHARSET', 'utf8'); define('DB_COLLATE', ''); - Reopen web service. That’s it.
Note: For future convenience, you might as well change the database default encoding to utf8.
FileZilla Rules
October 14, 2007 4:08 pm | In Tech | 1 Comment | hide文件名编码的问题能把人搞疯掉,现在我自己的网络里面,除非特别有必要,文件名的编码都一律用 UTF-8。尽管如此,各个系统之间互相操作还是一不小心就出乱码……
首先是 windows 文件共享/samba。Windows 自动用 UTF-8 没问题,smb.conf 需要配置 unix charset = UTF-8,smbmount 貌似自动用 UTF-8,Mac 下面也没问题。
然后是 shell/文件管理器下面看文件。这个一般只要 locale 设置为 UTF-8 就没有问题。如果从 windows 连上 MacOS/Linux 的 shell,还需要注意客户端的编码设置为 UTF-8 解码。MacOS shell 下用 ls 注意要加 -w 或者 -v 参数。
Secure file transfer 的话,MacOS/Linux 已经有 sftp server 了,剩下的问题都可以用 FileZilla 解决掉。Windows 架服务器用 FileZilla Server,选用 SSL/TLS support,允许并强制使用 explicit SSL/TLS,需要自己做一个证书。客户端的话,无论 Windows/MacOS/Linux 都可以用 FileZilla Client(版本 > 3.0),连 windows FileZilla Server 需要注意选择 ServerType: FTP over explicit TLS/SSL,连 MacOS/Linux 只要选用 sftp 即可。以前各个系统互通的时候 UTF-8 文件名可以搞死人,现在用 FileZilla 这套东西完全没有问题了。
补充一下,MacOS/Linux 如果在 UTF-8 locale 下,使用 lftp 命令行也很好,无论 FTP over explicit TLS/SSL 还是 sftp 都没问题,UTF-8 文件名也没问题。另外,MacOS 的 Fetch 改一下选项可以正确解码 FTP 上的 UTF-8 文件名,但是 sftp 貌似不行……还有,FileZilla Client 在 MacOS 下面貌似 bug 还比较多,希望越来越好。
没有乱码的日子很快乐。FileZilla 一统天下,UTF-8 千秋万代!
Tags: encoding, encryption, filezilla, ftp, utf8
This weblog is licensed under a
Creative Commons License.
Powered by WordPress. Theme based on Pool by Borja Fernandez.