Make Ruby 1.9 regard all source files to be UTF-8 encoded. (Even if recompiling the interpreter is necessary)

后端 未结 1 1542
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-23 15:23

I want to port a rails app from Ruby 1.8.7 to 1.9.2. Some of the files contain umlauts like ä/ö/ü both within strings and comments. The files were saved as UTF-8 but without

1条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-23 15:50

    I found a workaround: set the RUBYOPT environment variable, for example by executing

    export RUBYOPT=-Ku

    in your shell.

    This will set -Ku als default option when calling ruby. You can now call all other tools which invoke ruby without worrying about parameters. rails server or rake works and regards all files as UTF-8. No BOM or magic comments necessary!

    0 讨论(0)
提交回复
热议问题