【发布时间】:2011-01-23 02:35:39
【问题描述】:
我在从 Cloudmailin 接收 Rails 电子邮件时收到以下 PGError:
PGError: ERROR: invalid byte sequence for encoding "UTF8": 0xbb HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding". : INSERT INTO "comments" ("content") VALUES ('Reply with blah blah ����������������������������������������������������� .....
所以很明显我在电子邮件中输入了一些无效的 UTF8 字符,对吗?所以我试图清理它,但有些东西仍然在偷偷摸摸。到目前为止,这是我所拥有的:
message_all_clean = params[:message]
Iconv.conv('UTF-8//IGNORE', 'UTF-8', message_all_clean)
message_plain_clean = params[:plain]
Iconv.conv('UTF-8//IGNORE', 'UTF-8', message_plain_clean)
@incoming_mail = IncomingMail.create(:message_all => Base64.encode64(message_all_clean), :message_plain => Base64.encode64(message_plain_clean))
有什么想法、想法或建议吗?谢谢
【问题讨论】:
标签: ruby-on-rails postgresql ruby-on-rails-3 encoding heroku