Skip to content

Commit

Permalink
Replace LANG with LC_ALL
Browse files Browse the repository at this point in the history
  • Loading branch information
candlerb committed Aug 6, 2009
1 parent 407ae31 commit 730f4ab
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions string19.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def test_string19
# The choice of locale is made at runtime based on environment variables,
# see setlocale(3)

res = %x{env LANG=en_US.utf8 #{RUBY} -e "puts Encoding.locale_charmap"}.chomp
res = %x{env LC_ALL=en_US.utf8 #{RUBY} -e "puts Encoding.locale_charmap"}.chomp
is "UTF-8", res

# Quoting from the Encoding.locale_charmap documentation: "The result is
Expand All @@ -155,9 +155,9 @@ def test_string19

# On Linux systems, the 'C' locale maps to the ANSI_X3.4-1968 character set.

res = %x{env LANG=C #{RUBY} -e "puts Encoding.locale_charmap"}.chomp
res = %x{env LC_ALL=C #{RUBY} -e "puts Encoding.locale_charmap"}.chomp
if res != "ANSI_X3.4-1968"
STDERR.puts "WARNING: got #{res.inspect} as locale_charmap for LANG=C"
STDERR.puts "WARNING: got #{res.inspect} as locale_charmap for LC_ALL=C"
end

# On systems which have no locale support at all, the fallback is US-ASCII.
Expand Down Expand Up @@ -1255,19 +1255,19 @@ def b.to_str
# overridden using a #encoding line

is "UTF-8",
%x{ echo "puts ''.encoding" | env LANG=en_US.utf8 #{RUBY} }.chomp
%x{ echo "puts ''.encoding" | env LC_ALL=en_US.utf8 #{RUBY} }.chomp
is "ASCII-8BIT",
%x{ echo '#encoding:ASCII-8BIT\nputs "".encoding' | env LANG=en_US.utf8 #{RUBY} }.chomp
%x{ echo '#encoding:ASCII-8BIT\nputs "".encoding' | env LC_ALL=en_US.utf8 #{RUBY} }.chomp

# 18.3 Source on the command line
#
# This also defaults to the locale encoding, and can also be overridden
# using a #encoding line

is "UTF-8",
%x{ env LANG=en_US.utf8 #{RUBY} -e 'puts "".encoding' }.chomp
%x{ env LC_ALL=en_US.utf8 #{RUBY} -e 'puts "".encoding' }.chomp
is "ISO-8859-1",
%x{ env LANG=en_US.utf8 #{RUBY} -e '#encoding:ISO-8859-1' -e 'puts "".encoding' }.chomp
%x{ env LC_ALL=en_US.utf8 #{RUBY} -e '#encoding:ISO-8859-1' -e 'puts "".encoding' }.chomp

# 18.4 Source in eval
#
Expand Down Expand Up @@ -1573,7 +1573,7 @@ def b.to_str
# installed - here I will choose UTF-8 from the environment, but the source
# encoding is ISO-8859-1.

res = %x{ echo "abc" | env LANG=en_US.utf8 #{RUBY} -e "#encoding:ISO-8859-1" -e "puts ''.encoding; puts STDIN.gets.encoding"}.chomp
res = %x{ echo "abc" | env LC_ALL=en_US.utf8 #{RUBY} -e "#encoding:ISO-8859-1" -e "puts ''.encoding; puts STDIN.gets.encoding"}.chomp
is "ISO-8859-1\nUTF-8", res

# There is an accessor, Encoding.default_external=, which can be used
Expand Down Expand Up @@ -1688,7 +1688,7 @@ def b.to_str

# 22.3 Clean the environment
#
# You can explicitly set the LANG environment variable before running your
# You can explicitly set the LC_ALL environment variable before running your
# ruby script, or run with -Ku to force UTF-8 or -Kn to force ASCII-8BIT.
#
# The problem is, this won't work if your code is made up of individual
Expand All @@ -1700,7 +1700,7 @@ def b.to_str
# You can run your test suite under each environment which you expect to
# run under, or try to fake up those environments by installing the
# necessary locales on one system and then running the test suite multiple
# times with different LANG settings. This is a bit of a pain.
# times with different LC_ALL settings. This is a bit of a pain.

# 22.5 Expand test coverage
#
Expand Down Expand Up @@ -1731,7 +1731,7 @@ def b.to_str
private
def execute_in_file(str)
write_file(str) do |fn|
%x{ env LANG=en_US.utf8 #{RUBY} #{fn} 2>&1 }.chomp
%x{ env LC_ALL=en_US.utf8 #{RUBY} #{fn} 2>&1 }.chomp
end
end

Expand Down

0 comments on commit 730f4ab

Please sign in to comment.