What version of Ruby are you using Sergio?

The issue is probably that the string is being interpreted as latin rather than 
UTF-8 but is then being saved as UTF-8.

In 1.8.x you can use Iconv

In 1.9.2 the strings have the encoding baked in. Take a look at force_encoding, 
and encoding and also the magic comment #encoding:.

For example you could try "ç".force_encoding('ISO-8859-1').encode('UTF-8') 
since you know that this is actually latin.

We had a lot of issues with CloudMailin and encoding before we hit beta and 
unfortunately some of them still came out during the beta testing, making sure 
you have up to date versions of adapters will also help.

I hope that's of use,
Steve

On 11 Jan 2011, at 21:42, sergi_heroku wrote:

> Hi,
> 
> Anyone knows how to setup a web application that needs to store
> spanish accents (such as á, é, or í) in the ActiveRecord models.
> 
> When I use the Heroku  Console and I try to insert a string with
> Spanish characters in the model, I always get the following error:
> 
> "ActiveRecord :: StatementInvalid: PGError: invalid byte of sequence
> for encoding "UTF8" : 0x82".
> 
> For example, let's suppose that I want to store the title of a book in
> the model called "book".  From the Heroku Console, I type the
> following:
> 
>> b = Book.new
> 
>> b.title = "Configuración"  ( # title is the field for the title of a book. 
>> Note that the title has a spanish accent)
> 
>> b.save
> 
>>> I GET THE ERROR!  "ActiveRecord :: StatementInvalid: PGError: invalid byte 
>>> of sequence for encoding "UTF8" : 0x82".
> 
> I would really appreciate any hint to solve this problem.
> 
> Many many thanks,
> 
> Sergio
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Heroku" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/heroku?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Heroku" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.

Reply via email to