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 7415217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:15:29+00:00 2026-05-29T07:15:29+00:00

In a Rails 3.2 app (Ruby 1.9.2) I am getting the following errors A

  • 0

In a Rails 3.2 app (Ruby 1.9.2) I am getting the following errors

A PGError occurred in mobile_users#update:

incomplete multibyte character

These are Postgres errors bu I get similar SQLIte error when testing in dev and test modes

The params that cause this error are (auth token deliberately omitted)

  * Parameters: {"mobile_user"=>{"quiz_id"=>"1", "auth"=>"xxx", "name"=>"Joaqu\xEDn"}, "action"=>"update", "controller"=>"mobile_users", "id"=>"1", "format"=>"mobile"}

This is coming in as a JSON HTTP Put request and the update action dealing with this is as follows

  # PUT /mobile_users/1
  # PUT /mobile_users/1.xml
  def update
    @mobile_user = current_mobile_user
    @mobile_user.attributes = params[:mobile_user]

    respond_to do |format|
      if @mobile_user.save
        format.html { redirect_to(@mobile_user, :notice => 'Mobile user was successfully updated.') }
        format.json  { head :ok }
        format.mobile  { head :ok }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.json  { render :json => @mobile_user.errors, :status => :unprocessable_entity }
        format.mobile  { render :json => @mobile_user.errors, :status => :unprocessable_entity }
        format.xml  { render :xml => @mobile_user.errors, :status => :unprocessable_entity }
      end
    end

  end

The offending string is in the above params is “Joaqu\xEDn” which is perfectly valid.
the thing is that I need to handle all character sets from any language.

I assume I would need to use the iconv library but in order to do that I would need to detect the character set to convert to UTF8 from and I haven’t a clue how to do this.

I am also getting invalid byte sequence in UTF-8 for "name"=>"p\xEDa "

  • 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-29T07:15:30+00:00Added an answer on May 29, 2026 at 7:15 am

    This:

    "Joaqu\xEDn"
    

    is the ISO-8859-1 encoded version of "Joaquín" so it is not valid UTF-8 and your databases are right to complain about it. If possible, fix your mobile clients to use UTF-8 in the JSON; if you can’t do that then you can fix the encoding with this:

    params[:mobile_user][:name].force_encoding('iso-8859-1').encode!('utf-8')
    

    on the server. The problem with fixing it on the server is that you have to guess what the incoming encoding is and your guess might not be correct. There is no way to reliably guess the encoding for a particular string, there is rchardet but it doesn’t work with recent versions of Ruby and it appears to have been abandoned; you might be able to fix this gem to work with modern Ruby. There are a few other guessing libraries but they all seem to be have been abandoned as well.

    JSON text is always, by definition, Unicode and UTF-8 encoded by default:

    3.  Encoding
    
       JSON text SHALL be encoded in Unicode.  The default encoding is
       UTF-8.
    

    Any clients that are sending you JSON that isn’t in UTF-8 is IMO broken because almost everything will assume that JSON will be UTF-8. Of course, there might be an encoding header somewhere that specifies ISO 8859-1 or maybe the headers say UTF-8 even though it is ISO 8859-1.

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

Sidebar

Related Questions

In rails 3.0.9/ruby 1.9.2 I'm getting unexpected behaviour when i try to update model
I'm learning ruby on rails by following the tutorials in http://ruby.railstutorial.org/ . I'm getting
I'm getting started with Ruby on Rails and am following an online tutorial. The
I'm trying to deploy a rails app to heroku, but keep getting the following
Trying to setup a rails app and getting following error. Any ideas? b/tasks instead.
After upgrading my Rails 3.0.9 app to 3.1.1, I'm getting the following bundler error
This is more a general question but my particular case involves a ruby/rails app
In my Ruby on Rails app, I have a User table and a Foo
In my ruby on rails app I am trying to use a Prototype Form.Element.Observer
In a ruby on rails app, I build an array of Project Names and

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.