Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Gem::Text#clean_text
clean_text(text)
lib/rubygems/text.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/text.rb, line 10
def clean_text(text)
text = text.gsub(/[\000-\b\v-\f\016-\037\177]/, ".")
# Match C1 control characters (U+0080-U+009F) as codepoints. This requires
# a valid UTF-8 string so the regexp does not split a multibyte sequence;
# strings in other encodings are left unchanged.
if text.encoding == Encoding::UTF_8 && text.valid_encoding?
text = text.gsub(/[\u0080-\u009f]/, ".")
end
text
end
Remove any non-printable characters and make the text suitable for printing.