Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6568257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:27:19+00:00 2026-05-25T14:27:19+00:00

I have a Rails 3.0.9 application running both locally in my dev env and

  • 0

I have a Rails 3.0.9 application running both locally in my dev env and remotely on a heroku app. I have a method that imports a CSV file into a model, and this file can contain non-english characters, like °,á,é,í, etc (it’s in spanish).

I am currently able to import the complete file (75k records) without any problems in my local dev (SQLite) database; but, when uploading the db to heroku with heroku db:push, it fails with the error I’m posting in the title:

!!! Caught Server Exception

HTTP CODE: 500
Taps Server Error: PGError: ERROR:  invalid byte sequence for encoding "UTF8": 0xba
HINT:  This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding".

Apparently, Heroku has issues inserting the ‘°’ character. (At the moment the file doesn’t have any á,é,í, etc characters, but I suspect these might fail too.)

I have set in my application.rb file the default encoding, as follows:

#.../application.rb
config.encoding = "utf-8"

What else can I do to set the ‘client encoding’ and solve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:27:19+00:00Added an answer on May 25, 2026 at 2:27 pm

    The numero sign, º, is 0xBA in ISO-8869-1 not UTF-8. So your CSV file is encoded with Latin-1 but you’re trying to store it in your database as UTF-8 without fixing the encoding.

    You can try telling your CSV library that it is dealing with Latin-1 encoded text and maybe it will take care of converting to UTF-8. If that doesn’t work, then you can do it yourself with Iconv:

    ruby-1.9.2 > Iconv.iconv('UTF-8', 'ISO-8859-1', "\xba")
     => ["º"]
    ruby-1.9.2 > Iconv.iconv('UTF-8', 'ISO-8859-1', "\xb0")
     => ["°"]
    

    You’re not having trouble with SQLite because SQLite tends be very forgiving and it has a very loose type system. PostgreSQL, OTOH, tends to be rather strict and properly complains if you try to feed it invalid data. I’d recommend that you stop developing on top of SQLite if you’re going to be deploying to Heroku and PostgreSQL, there are other differences that will cause problems (the behavior of GROUP BY and LIKE for example).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails app running on Heroku. I am using paperclip for some
We have a Rails application that is running in a MySQL master-slave set-up for
I have a rails application running on a Linux server. I would like to
I have a Rails 2.0.2 application running with a postgresql db. The machine will
I have a rails application, running in development mode ( with a sqlite database
I have a Rails + Apache2 + Postgres + Passenger application running in production
I have a RoR application running on box1...it obviously has Ruby, RubyGems, and Rails
I have a simple rails 2.3.4 application I am trying to get running with
I have a Rails application that in the erb code, I use a select
We have a rails application in subversion that we deploy with Capistrano but have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.