Method: Mail::Message#body_in_utf8

Defined in:
app/models/post.rb

#body_in_utf8Object

This returns the message body in utf8 encoding.



154
155
156
157
158
159
160
161
162
163
164
# File 'app/models/post.rb', line 154

def body_in_utf8
  CharlockHolmes
  require 'charlock_holmes/string'

  body = self.body.decoded
  if body.present?
    encoding = body.detect_encoding[:encoding]
    body = body.force_encoding(encoding).encode('UTF-8')
  end
  return body
end