Skip to content
Permalink
Browse files

Recognise en_US.utf8 as UTF-8 (fixes #335)

  • Loading branch information...
ddfreyne committed Oct 2, 2013
1 parent c922faf commit 1a95618717d5ef3bea8e19007cd18321eff9adbf
Showing with 11 additions and 2 deletions.
  1. +2 −2 lib/nanoc/cli.rb
  2. +9 −0 test/cli/test_cli.rb
@@ -184,7 +184,7 @@ def self.setup_cleaning_streams
def self.enable_utf8?(io)
return true if !io.tty?

%w( LC_ALL LC_CTYPE LANG ).any? { |e| ENV[e] =~ /UTF/ }
%w( LC_ALL LC_CTYPE LANG ).any? { |e| ENV[e] =~ /UTF/i }
end

# @return [Boolean] true if color support is present, false if not
@@ -196,7 +196,7 @@ def self.enable_ansi_colors?(io)
rescue LoadError
return false
end

return true
end

@@ -130,9 +130,18 @@ def io.tty? ; true ; end
}
with_env_vars(new_env_diff) do
refute Nanoc::CLI.enable_utf8?(io)

with_env_vars({ 'LC_ALL' => 'en_US.UTF-8' }) { assert Nanoc::CLI.enable_utf8?(io) }
with_env_vars({ 'LC_CTYPE' => 'en_US.UTF-8' }) { assert Nanoc::CLI.enable_utf8?(io) }
with_env_vars({ 'LANG' => 'en_US.UTF-8' }) { assert Nanoc::CLI.enable_utf8?(io) }

with_env_vars({ 'LC_ALL' => 'en_US.utf-8' }) { assert Nanoc::CLI.enable_utf8?(io) }
with_env_vars({ 'LC_CTYPE' => 'en_US.utf-8' }) { assert Nanoc::CLI.enable_utf8?(io) }
with_env_vars({ 'LANG' => 'en_US.utf-8' }) { assert Nanoc::CLI.enable_utf8?(io) }

with_env_vars({ 'LC_ALL' => 'en_US.utf8' }) { assert Nanoc::CLI.enable_utf8?(io) }
with_env_vars({ 'LC_CTYPE' => 'en_US.utf8' }) { assert Nanoc::CLI.enable_utf8?(io) }
with_env_vars({ 'LANG' => 'en_US.utf8' }) { assert Nanoc::CLI.enable_utf8?(io) }
end
end

0 comments on commit 1a95618

Please sign in to comment.
You can’t perform that action at this time.