我收到“不兼容的字符编码:CP850和UTF-8”当我的ramaze应用程序显示£符号 [英] I receive "incompatible character encodings: CP850 and UTF-8" when displaying the £ symbol on my ramaze app
问题描述
£
符号时,我收到不兼容的字符编码:CP850和UTF-8。我如何摆脱这个错误?我的头标中有UTF-8元标记。 当我输入£
符号时,会发生键盘。看。
我将以下代码放在我的ruby文件中并没有解决问题。
#encoding:UTF-8
Encoding.default_external ='utf- 8'
Encoding.default_internal = Encoding :: UTF_8
your_string.force_encoding(:: Encoding: :UTF_8)
如果这样做,潜入你的应用程序,并发现设置错误的编码是什么,哪里,以及为什么。
可能是与服务器/网页相关的,因为您所提供的页面由于标题而呈现为US-ASCII。或者服务器以UTF-8以外的编码启动。或者其他这样的事情。您的脚本最后一块不是UTF-8的外部数据。
I receive "incompatible character encodings: CP850 and UTF-8" when displaying the £
symbol on my ramaze app. How can I get rid of this error? I have the UTF-8 meta tag in my head tag.
It happens when I type the £
symbol with the keyboard. Look.
I have put the following code in my ruby file and it hasn't fixed the problem.
# encoding: UTF-8
Encoding.default_external = 'utf-8'
Encoding.default_internal = Encoding::UTF_8
Try to force the encoding to see if that makes the problem go away:
your_string.force_encoding(::Encoding::UTF_8)
If it does, dive into your app and spot what is setting the wrong encoding, where, and why.
It's possibly server-/webpage-related, as in the page you're serving is rendered as US-ASCII owing to a header. Or the server is started with encoding other than UTF-8. Or something other to that effect. Your script ends up with a piece of external data that isn't UTF-8.
这篇关于我收到“不兼容的字符编码:CP850和UTF-8”当我的ramaze应用程序显示£符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!