Encode UTF-8 for strings with accents

Hello,

I have a problem to show some strings.
I am French. There are a lot of characters with accents in my language.

My problem is when I want to show a user profile, I got this error:

incompatible character encodings: UTF-8 and ASCII-8BIT

The first name of this user is “Jérémy”.
In the console, I got: “J\xC3\xA9r\xC3\xA9my”

I find a solution: use force_encoding(“utf-8”)

“J\xC3\xA9r\xC3\xA9my”.force_encoding(“utf-8”)
return “Jérémy”

Is there the best solution to encode all strings with utf-8?

I searched on StackOverFlow and other websites.
I change the encoding of my database (I use mysql2), modify the database config, add “#encoding: utf-8” at the top html.erb view, but I don’t find the best solution.

Thank you for your help

Hello,

I find a solution !

I used:

I18n.transliterate(full_name)

with all variables.

Don’t forget to use it in UserMailer.