默认情况下,驱动程序 Perl/MySQL 处理二进制数据(至少我从 MySQL 5.1 和 5.5 的一些实验中得出了这一结论)。
在没有设置 mysql_enable_utf8 的情况下,我在向/从数据库写入/读取之前对字符串进行了编码/解码到 UTF-8/从 UTF-8 编码/解码。
它不应该依赖于 perl 内部的字符串表示作为字节数组;请注意,内部的“utf8”不保证是标准的 UTF-8;相反,单字节编码不保证是 ISO-8859-1;真的对UTF-8(而不是'utf8')进行编码/解码。
There are also some settings of MySQL (like SET NAMES above, as far as I remember there is a client encoding, a connection encoding, and a server encoding, whose interactions are not quite clear to me if they do not all have the same value) regarding to the encodings; setting all of them to UTF-8, and the recipe above, worked for me.