I want to tell ruby that everything is utf8, except when stated otherwise, so I dont have to place these # encoding: utf-8
comments everywhere.
If you're using environment variables, the general way is to use LC_ALL / LANG
Neither is set : fallback to US-ASCII
$ LC_ALL= LANG= ruby -e 'p Encoding.default_external'
#<Encoding:US-ASCII>
Either is set : that value is used
$ LC_ALL=en_US.UTF-8 LANG= ruby -e 'p Encoding.default_external'
#<Encoding:UTF-8>
$ LC_ALL= LANG=en_US.UTF-8 ruby -e 'p Encoding.default_external'
#<Encoding:UTF-8>
Both are set : LC_ALL takes precedence
$ LC_ALL=C LANG=en_US.UTF-8 ruby -e 'p Encoding.default_external'
#<Encoding:US-ASCII>
$ LC_ALL=en_US.UTF-8 LANG=C ruby -e 'p Encoding.default_external'
#<Encoding:UTF-8>
You can either:
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