续集永远不会返回utf-8,只是ascii-8bit [英] sequel never returns utf-8, just ascii-8bit

查看:102
本文介绍了续集永远不会返回utf-8,只是ascii-8bit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试连接到这个mysql数据库。 DataMapper在UTF-8中很好地获取所有内容,但Sequel始终返回ASCII-8bit中的字符串,它会导致.to_json的错误。



我已经尝试了几件事,工作。

  Encoding.default_external = Encoding :: UTF_8 
Encoding.default_internal = Encoding :: UTF_8
DB.run'set names utf8'
Sequel.mysql'db',(...),:encoding => 'utf-8'

我有宝石:mysql(2.9.0)(试过没),mysql2 (0.3.11)和续集(3.42.0)



唯一有效的方法是手动强制每个字符串的编码少于理想值。

解决方案

尝试 Sequel.mysql2 而不是 Sequel.mysql Sequel.mysql 使用旧的 mysql 驱动程序,而不是新的 mysql2 驱动程序,我不相信 mysql 驱动程序支持编码。


There is this mysql database I'm trying to connect to. DataMapper fetches everything nicely in UTF-8 but Sequel always returns strings in ASCII-8bit which produces errors with .to_json.

I have tried several things in order to get it to work.

Encoding.default_external = Encoding::UTF_8  
Encoding.default_internal = Encoding::UTF_8  
DB.run 'set names utf8'  
Sequel.mysql 'db', (...), :encoding => 'utf-8'  

I have gems: mysql (2.9.0) (tried without), mysql2 (0.3.11) and sequel (3.42.0)

The only thing that works is manually forcing the encoding on every string which is MUCH less than ideal.

解决方案

Try Sequel.mysql2 instead of Sequel.mysql. Sequel.mysql uses the old mysql driver instead of the new mysql2 driver, and I don't believe the mysql driver supports encodings.

这篇关于续集永远不会返回utf-8,只是ascii-8bit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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