很奇怪的编码错误有时只会发生(Very weird encoding error happening only sometimes)

编程入门 行业动态 更新时间:2024-10-25 04:23:58
很奇怪的编码错误有时只会发生(Very weird encoding error happening only sometimes)

我们使用的是Rails 3.2.3,Ruby 1.9.1和HAML。 我们有一个Post模型,有时只有在Internet Explorer 9中才会发生非常奇怪的事情。

ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT):

错误在以下行中:

= raw @post.content

Wich从数据库中返回帖子的内容。 请注意,内容包含HTML标记。

奇怪的是:

该错误仅在使用IE 9的某些计算机上显示。(我们无法在使用相同IE 9版本的其他计算机上重现该错误) 错误有时只会发生。

我们试过这个机智没有运气(同样的错误):

= raw @post.content.force_encoding('utf-8')

任何见解? 提前致谢。

更新现在几次更改后,错误显示在以下行中:

37: .social

那一行没有什么奇怪的东西,只有空格(不是制表符)和“.social”字符串。 这太疯狂了。

We're using Rails 3.2.3, Ruby 1.9.1, and HAML. We have a Post model and there is something very weird happening only sometimes and only in Internet Explorer 9.

ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT):

The error is in the following line:

= raw @post.content

Wich returns the post's content from the database. Note the content has HTML tags.

Weird things are:

The error only shows on some machines with IE 9. (We can't reproduce the error in other machines using the same IE 9 build) The error only happens sometimes.

We've tried this wit no luck (same error):

= raw @post.content.force_encoding('utf-8')

Any insight? Thanks in advance.

Update After a few changes now the error shows up in the following line:

37: .social

There is nothing weird in that line, just spaces (not tabs) and the ".social" string. This is crazy.

最满意答案

好的,终于找到了问题。 那是个

= link_to "Back" :back

这里有更好的解释: link_to中的非ascii字符导致应用程序在rails app中的Internet Explorer 9中失败

Ok, finally found the issue. It was a

= link_to "Back" :back

It's better explained here: Non ascii characters in link_to is causing the app to fail in internet explorer 9 in rails app

更多推荐

本文发布于:2023-08-01 11:11:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1357736.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:只会   很奇怪   错误   发生   error

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!