Class: Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/filters/utils.rb

Overview

Utility class

Class Method Summary collapse

Class Method Details

.removeInvalidChars(str) ⇒ Object

Sanitize a UTF 8 string : remove invalid characters



7
8
9
10
11
12
# File 'lib/logstash/filters/utils.rb', line 7

def self.removeInvalidChars(str)
  if(str && !str.valid_encoding?)
    return str.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: "")
  end
  return str
end