summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/irb/xmp.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/irb/xmp.rb b/lib/irb/xmp.rb
index 851852cd3e..af87b48887 100644
--- a/lib/irb/xmp.rb
+++ b/lib/irb/xmp.rb
@@ -72,8 +72,20 @@ class XMP
end
def puts(exps)
+ if @encoding and exps.encoding != @encoding
+ enc = Encoding.compatible?(@exps.join("\n"), exps)
+ if enc.nil?
+ raise Encoding::CompatibilityError, "Encoding in which the passed exression is encoded is not compatible to the preceding's one"
+ else
+ @encoding = enc
+ end
+ else
+ @encoding = exps.encoding
+ end
@exps.concat exps.split(/\n/)
end
+
+ attr_reader :encoding
end
end