The following code works without problem:
#encoding: utf-8
class Text
def initialize(txt)
@txt = txt
end
def inspect
"<Text: %s>" % @txt
end
end
p Text.new('Hello World')
But if I try p Text.new('Hä, was soll das?')
I get a Encoding::CompatibilityError:
inspect_with_umlaut.rb:26:in `p': inspected result must be ASCII only or use the default external encoding (Encoding::CompatibilityError)
from inspect_with_umlaut.rb:26:in `<main>'
Why this?
And more important: How can I avoid it?