sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 414ae18131aae7bbe7a828364c1675b575853590
parent c578ee67b08e490f4c314a90aee4401c32b74ae9
Author: Gaute Hope <eg@gaute.vetsj.com>
Date:   Fri, 31 May 2013 15:52:07 +0200

Merge #76: Accept UTF8 as UTF-8 and test encoding with fallback to UTF-8

Fixes #71.

Squashed commit of the following:

commit 9ce3664e296fb190473717bcd08e772184ff8242
Author: Gaute Hope 
Date:   Wed May 29 08:33:26 2013 +0200

    test encoding and fallback to utf-8

commit b17e917565e0a13671c0aaf08c22bfbf63ff5bb4
Author: Gaute Hope 
Date:   Wed May 29 00:12:16 2013 +0200

    accept UTF8 as UTF-8

Diffstat:
M lib/sup.rb | 11 +++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -315,6 +315,7 @@ require "sup/logger/singleton"
 ## determine encoding and character set
 $encoding = Locale.current.charset
 $encoding = "UTF-8" if $encoding == "utf8"
+$encoding = "UTF-8" if $encoding == "UTF8"
 if $encoding
   debug "using character set encoding #{$encoding.inspect}"
 else
@@ -322,6 +323,16 @@ else
   $encoding = "UTF-8"
 end
 
+# test encoding
+teststr = "test"
+teststr.encode('UTF-8')
+begin
+  teststr.encode($encoding)
+rescue Encoding::ConverterNotFoundError
+  warn "locale encoding is invalid, defaulting to utf-8"
+  $encoding = "UTF-8"
+end
+
 require "sup/buffer"
 require "sup/keymap"
 require "sup/mode"