Possible Duplicate:
Ruby - UTF-8 file encoding
I'm using UTF-8 all the way and want to help the ruby interpreter to read my files.
Therefore I put # encoding=utf-8
at the start of my ruby code like this:
#!/usr/bin/env ruby
# encoding=utf-8
But now and then, I see other variants:
bundle gem NAME
inserts # -*- encoding: utf-8 -*-
(into NAME.gemspec). The gem magic_encoding uses this line, too.
What is the recommended way?
# encoding = utf-8
# encoding: utf-8
# -*- encoding: utf-8 -*-
Short answer:
# encoding: utf-8
This is a complete answer: Ruby - UTF-8 file encoding
It looks like a fairly relaxed specification for what's acceptable. I've always used:
# encoding: UTF-8
Also acceptable is coding
. I can't find a reference on the variants allowed, but so long as your file is being interpreted correctly it should be fine. Check the __ENCODING__
value to be sure it's being picked up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With