在法语文件中放置法语(带重音)字符 [英] Putting French (accented) characters in Ruby file
本文介绍了在法语文件中放置法语(带重音)字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Possible Duplicate:
invalid multibyte char (US-ASCII) with Rails and Ruby 1.9
如何将法语字符放入Ruby文件?这是一个错误:
How can I put French characters in a Ruby file? Here is an error:
SyntaxError in ArticlesController#show
/.../app/controllers/articles_controller.rb:47: invalid multibyte char (US-ASCII)
/.../app/controllers/articles_controller.rb:47: invalid multibyte char (US-ASCII)
/.../app/controllers/articles_controller.rb:47: syntax error, unexpected $end, expecting '}'
...@article, notice: 'Article a été créé avec succes.' }
在HTML文件中,将其放在首位即可,并且带有重音符号:
In a HTML file a put this in head and the accents work:
<!DOCTYPE html>
<head>
<meta http-equiv="content-type" content="text/html"; charset="utf8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Style-Type" content="text/css">
<!-- ... autres mentions de l'entête de fichier ... -->
</head>
推荐答案
Ruby有一种特殊的语法来声明文件的字符集:如果您使用的是多字节字符,则可以在 very top 文件,没有前面的空格
Ruby has a special syntax for declaring the charset of a file: if you are using multibyte characters, you can use this line at the very top of your file, with no preceding whitespace
# encoding: utf-8
这篇关于在法语文件中放置法语(带重音)字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文