As you probably know, the source/script encoding can be specified by putting a "magic comment" line as the first or second line of a Ruby file. Being a Vim user, I have used a "magic comment" line like this # NOTE: vim: fileencoding=UTF-8 Thus, the line could be used by Ruby as well as Vim. I first learned about the "magic comment" line from the book "The Ruby Programming Language" by David Flanagan and Matz. According to the book, the syntax rules for the line are: The comment must be written entirely in ASCII, and must include the string "coding" followed by a colon or equals sign and the name of the desired encoding (which cannot include spaces or punctuation other than hyphen and underscore). Whitespace is allowed on either side of the colon or equals sign, and the string "coding" may have any prefix, such as "en" to spell "encoding". However, the documentation http://www.ruby-doc.org/core-2.0.0/Encoding.html does not entirely agree: The default script encoding is Encoding::US-ASCII, but it can be changed by a magic comment on the first line of the source code file (or second line, if there is a shebang line on the first). The comment must contain the word "coding" or "encoding", followed by a colon, space and the Encoding name or alias. Now, according to the Ruby documentation, the Vim modeline shown above is invalid as a Ruby "magic comment" line. It does work, however. Ruby picks up the specified encoding just fine (only tried with Ruby 1.9.3 and 2.0.0). So, am I to trust the book or the documentation?
on 2014-02-12 09:21
on 2014-02-18 07:58
<a href="http://www.changeyourlifespells.com/about.php" title="Free Magick Spell" name="Free Magick Spell"><img src="http://www.real-wishes.com/images/wish-3.jpg" alt="Free Magick Spell" title="Free Magick Spell" /><br>Free Magick Spell</a>
on 2014-02-25 07:25
No one knows the correct rules about the "coding comment" line?
on 2014-02-26 03:38
On Tue, Feb 25, 2014 at 12:25 AM, Claus Folke Brobak <firstname.lastname@example.org>wrote: > No one knows the correct rules about the "coding comment" line? > > -- > Posted via http://www.ruby-forum.com/. > Your Vim-compatible modeline does work; so I think there is just an error in the Ruby documentation.