Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Add magic encoding comment to generated files

#3989

Hi,

In a brand new Rails 3.0.0.beta application, I created the following controller :

class TestController < ApplicationController
  
  def index
    @test = "héhé"
  end

end

But I get the following error when I try to access it :

/Users/antho/workspace/bugchar/app/controllers/test_controller.rb:4: invalid multibyte char (US-ASCII)
/Users/antho/workspace/bugchar/app/controllers/test_controller.rb:4: invalid multibyte char (US-ASCII)
/Users/antho/workspace/bugchar/app/controllers/test_controller.rb:4: syntax error, unexpected $end, expecting keyword_end
    @test = "héhé"

ruby 1.9.1p243 (2009-07-16 revision 24175) [i386-darwin9.8.0]
Rails 3.0.0.beta

Any ideas?

Thanks,

Anthony

Reported by ahe · February 18th, 2010 @ 03:02 PM

State: invalid
Milestone: none
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: Low

Activity

  1. Norman Clarke
    Norman Clarke

    You probably need to add an encoding comment to the top of the file. For example:

    # encoding: utf-8
    

    April 8th, 2010 @ 03:57 AM

  2. Norman Clarke
    Norman Clarke
    • Tag changed from rails3 to invalid, rails3

    April 13th, 2010 @ 01:26 PM

  3. Ryan Bigg
    Ryan Bigg
    • Tag changed from invalid, rails3 to 3.0

    Please do not go around marking tickets as invalid without confirmation from the OP that it fixes the problem or someone verifies it clearly.

    April 14th, 2010 @ 04:24 AM

  4. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to invalid

    Good case for marking invalid, actually :) This will be a common Ruby issue. You have to state your source encoding if you use non US-ASCII chars in your string literals, regexps, method names, etc.

    April 14th, 2010 @ 05:08 AM

  5. M-Ryan
    M-Ryan
    • Importance changed from to Low

    I created a small tool to set magic comments on large number of source files quickly.
    It's called magic_encoding, it's still very early in development but it's already functionnal (gem install magic_encoding)

    Source : http://github.com/m-ryan/magic_encoding)

    August 3rd, 2010 @ 01:55 PM

  6. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 9th, 2010 @ 10:12 PM

  7. Ryan Bigg
    Ryan Bigg

    Automatic cleanup of spam.

    October 21st, 2010 @ 03:40 AM

  8. Jeff Kreeftmeijer
  9. Jeff Kreeftmeijer
  10. Jeff Kreeftmeijer
  11. bingbing