[前][次][番号順一覧][スレッド一覧]

ruby-changes:60514

From: aycabta <ko1@a...>
Date: Thu, 26 Mar 2020 17:44:36 +0900 (JST)
Subject: [ruby-changes:60514] 69cd27c98e (master): [ruby/reline] Suppress error when check ambiguous char width in LANG=C

https://git.ruby-lang.org/ruby.git/commit/?id=69cd27c98e

From 69cd27c98eafd8711056825cf6c378eee282ffaa Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Tue, 24 Mar 2020 13:56:22 +0900
Subject: [ruby/reline] Suppress error when check ambiguous char width in
 LANG=C

https://github.com/ruby/reline/commit/623dffdd75

diff --git a/lib/reline.rb b/lib/reline.rb
index 2708cd9..1537ee7 100644
--- a/lib/reline.rb
+++ b/lib/reline.rb
@@ -336,8 +336,14 @@ module Reline https://github.com/ruby/ruby/blob/trunk/lib/reline.rb#L336
       @ambiguous_width = 2 if Reline::IOGate == Reline::GeneralIO or STDOUT.is_a?(File)
       return if ambiguous_width
       Reline::IOGate.move_cursor_column(0)
-      output.write "\u{25bd}"
-      @ambiguous_width = Reline::IOGate.cursor_pos.x
+      begin
+        output.write "\u{25bd}"
+      rescue Encoding::UndefinedConversionError
+        # LANG=C
+        @ambiguous_width = 1
+      else
+        @ambiguous_width = Reline::IOGate.cursor_pos.x
+      end
       Reline::IOGate.move_cursor_column(0)
       Reline::IOGate.erase_after_cursor
     end
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]