summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorMatthias Hecker <mail@apoc.cc>2020-04-02 09:19:40 +0200
committerMatthias Hecker <mail@apoc.cc>2020-04-02 09:19:40 +0200
commit7b792bea7a644309623d67b5d49528ae13da3e7b (patch)
tree3f93a19ab14c98aefe82f49f9661feba2adef7dd /lib/rbot
parentb22038a43a626915c6f70debf63f732053309a75 (diff)
plugin(search): fix search and gcalc, closes #28, #29
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/core/utils/extends.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/rbot/core/utils/extends.rb b/lib/rbot/core/utils/extends.rb
index 11ebfc61..08278261 100644
--- a/lib/rbot/core/utils/extends.rb
+++ b/lib/rbot/core/utils/extends.rb
@@ -380,6 +380,18 @@ class ::String
return txt
end
+
+ # Removes non-ASCII symbols from string
+ def remove_nonascii(replace='')
+ encoding_options = {
+ :invalid => :replace, # Replace invalid byte sequences
+ :undef => :replace, # Replace anything not defined in ASCII
+ :replace => replace,
+ :universal_newline => true # Always break lines with \n
+ }
+
+ self.encode(Encoding.find('ASCII'), encoding_options)
+ end
end
# Extensions to the Regexp class, with some common and/or complex regular