From mboxrd@z Thu Jan 1 00:00:00 1970 From: wmorgan-sup@masanjin.net (William Morgan) Date: Sat, 12 Jan 2008 18:22:58 -0800 Subject: [sup-talk] the proper way of determining the encoding In-Reply-To: <1199925510-sup-7503@clarabella.clarabella> References: <1199569265-sup-4567@clarabella.clarabella> <1199685831-sup-2011@south> <1199695733-sup-2741@clarabella.clarabella> <1199901555-sup-2661@south> <1199925510-sup-7503@clarabella.clarabella> Message-ID: <1200190710-sup-6881@south> Excerpts from Giorgio Lando's message of Wed Jan 09 16:39:10 -0800 2008: > I am not a mac user, but it works fine for me! I think I've found a better way, although it introduces yet another dependency, to the 'gettext' gem. I'd be interested to see if this works for you, Giorgio, and also for anyone who's running Sup under Cygwin or OS X. This is an approach I feel a lot better about. diff --git a/Rakefile b/Rakefile index 2f2b992..d4060c1 100644 --- a/Rakefile +++ b/Rakefile @@ -17,7 +17,7 @@ Hoe.new('sup', Redwood::VERSION) do |p| p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[2].gsub(/^\s+/, "") p.changes = p.paragraphs_of('History.txt', 0..0).join("\n\n") p.email = "wmorgan-sup at masanjin.net" - p.extra_deps = [['ferret', '>= 0.10.13'], ['ncurses', '>= 0.9.1'], ['rmail', '>= 0.17'], 'highline', 'net-ssh', ['trollop', '>= 1.7'], 'lockfile', 'mime-types'] + p.extra_deps = [['ferret', '>= 0.10.13'], ['ncurses', '>= 0.9.1'], ['rmail', '>= 0.17'], 'highline', 'net-ssh', ['trollop', '>= 1.7'], 'lockfile', 'mime-types', 'gettext'] end rule 'ss?.png' => 'ss?-small.png' do |t| diff --git a/lib/sup.rb b/lib/sup.rb index 5bb27ba..064e0af 100644 --- a/lib/sup.rb +++ b/lib/sup.rb @@ -3,6 +3,7 @@ require 'yaml' require 'zlib' require 'thread' require 'fileutils' +require 'gettext' require 'curses' class Object @@ -225,9 +226,8 @@ module Redwood module_function :log end -## determine encoding and character set. there MUST be a better way to -## do this. - $encoding = `locale -c LC_CTYPE|head -6|tail -1`.chomp +## determine encoding and character set + $encoding = Locale.current.charset if $encoding Redwood::log "using character set encoding #{$encoding.inspect}" else -- 1.5.4.rc2.60.gb2e62-dirty -- William