sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 6af3048fe82f48f0368a619ea785f0a394b0bbd4
parent 9722a770cadd44ddc4af6ddcb56eb8edb35c93b9
Author: William Morgan <wmorgan-sup@masanjin.net>
Date:   Wed,  9 Jan 2008 08:30:30 -0800

detect character set correctly (but unix-centrically)

Diffstat:
M lib/sup.rb | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -49,16 +49,6 @@ module Redwood
   YAML_DOMAIN = "masanjin.net"
   YAML_DATE = "2006-10-01"
 
-## determine encoding and character set
-## probably a better way to do this
-  $ctype = ENV["LC_CTYPE"] || ENV["LANG"] || "en-US.utf-8"
-  $encoding =
-    if $ctype =~ /\.(.*)?/
-      $1
-    else
-      "utf-8"
-    end
-
 ## record exceptions thrown in threads nicely
   def reporting_thread name
     if $opts[:no_threads]
@@ -235,6 +225,16 @@ 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
+  if $encoding
+    Redwood::log "using character set encoding #{$encoding.inspect}"
+  else
+    Redwood::log "warning: can't find character set by using locale, defaulting to utf-8"
+    $encoding = "utf-8"
+  end
+
 ## now everything else (which can feel free to call Redwood::log at load time)
 require "sup/update"
 require "sup/suicide"