Reputation: 2621
I'm getting the following error with my Ruby 1.9
I tried using (as some resources suggested)
string.force_encoding('utf-8')
But it didn't help!
Any ideas how to resolve this? Is there a way to eliminate such characters before saving to DB? or is a there a way to make them show?
For example, when I want to print:
Opowieść o kulcie przemocy
I get:
Opowie?? o kulcie przemocy
Upvotes: 1
Views: 1252
Reputation: 11011
I make it work using this first line of code:
# encoding: UTF-8
string = "Opowieść o kulcie przemocy"
p string.force_encoding('utf-8')
when i write to the DB , I use the encode and not the force_encoding , for example:
conn.exec(sql.encode("UTF-8"))
where sql is the statement containing the text that needs to be encoded
Upvotes: 1