sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit d3da1a118c7ba3d7bdb6e1b9dc757b78a26db8a6
parent c46d92e2fa2ca586763d78a4bf9d1b525b1ec0a4
Author: Rich Lane <rlane@club.cc.cmu.edu>
Date:   Thu, 31 Dec 2009 15:36:52 -0800

add String#ascii

Diffstat:
M lib/sup/util.rb | 13 +++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)
diff --git a/lib/sup/util.rb b/lib/sup/util.rb
@@ -306,6 +306,19 @@ class String
       raise CheckError.new($!.message)
     end
   end
+
+  def ascii
+    out = ""
+    each_byte do |b|
+      if (b & 128) != 0
+        out << "\\x#{b.to_s 16}"
+      else
+        out << b.chr
+      end
+    end
+    out.force_encoding Encoding::UTF_8 if out.respond_to? :force_encoding
+    out
+  end
 end
 
 class Numeric