module OnebusawaySDK::Internal::Util

def force_charset!(content_type, text:)

Parameters:
  • text (String) --
  • content_type (String) --

Other tags:
    Api: - private
def force_charset!(content_type, text:)
  charset = /charset=([^;\s]+)/.match(content_type)&.captures&.first
  return unless charset
  begin
    encoding = Encoding.find(charset)
    text.force_encoding(encoding)
  rescue ArgumentError
    nil
  end
end