Module: RubySMB::Utils

Included in:
Dcerpc::Client
Defined in:
lib/ruby_smb/utils.rb

Class Method Summary collapse

Class Method Details

.safe_encode(str, encoding) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/ruby_smb/utils.rb', line 4

def self.safe_encode(str, encoding)
  str.encode(encoding)
rescue EncodingError
  if str.encoding == ::Encoding::ASCII_8BIT
    str.dup.force_encoding(encoding)
  else
    raise
  end
end