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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:50:10+00:00 2026-06-03T04:50:10+00:00

Rails 3.2.2 Ruby 1.9.3 all browsers I have tried (Aurora, IE, Chrome) Windows 7

  • 0

Rails 3.2.2
Ruby 1.9.3
all browsers I have tried (Aurora, IE, Chrome)
Windows 7

I have enjoyed being able to reliably pass unicode back and forth between the database and the client. So far as I have been able to tell it works flawlessly.

However that only makes the problem I am having even more vexing. When working within Rails with string literals that contain various special characters (in a method defined for a model for example) I am causing Webrick to completely fail, and return a 500 “We’re sorry, but something has happened” error.

For example suppose I have the string “O₂”. I can post that value into a form and get it again later on and everything comes out fine. But say I have a method

def fix_name molecule_name 
  fixed_name = molecule_name
  case molecule_name
  when 'O2' then fixed_name = 'O₂'
  end
  return fixed_name
end

Then if I call fix_name, even if the case falls through without matching, the server fails abruptly (right after saying it has successfully rendered the generic new.html page).

Furthermore, if I switch to specifying unicode directly, as in

def fix_name molecule_name 
  fixed_name = molecule_name
  case molecule_name
  when 'O2' then fixed_name = "O\x20\x82"
  end
  return fixed_name
end

I get the generic “�” character instead of “₂”.

Has anyone else had this problem? What could be going on here?

updated

Okay, having educated myself a little better on Unicode and UTF-8 I am able to be a little less neanderthal about this.

The fix for the code I posted is either

def fix_name molecule_name 
  fixed_name = molecule_name
  case molecule_name
  when 'O2' then fixed_name = "O\xe2\x82\x82"
  end
  return fixed_name
end

or probably better:

def fix_name molecule_name 
  fixed_name = molecule_name
  case molecule_name
  when 'O2' then fixed_name = "O\u{2082}"
  end
  return fixed_name
end

So the moral there is to get the byte code right!

But that still doesn’t explain why I can’t put the literal character in.

  • 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-06-03T04:50:11+00:00Added an answer on June 3, 2026 at 4:50 am

    Ruby 1.9.3 is, let us say, ‘stringent’ about encoding in your rb files.

    http://yehudakatz.com/2010/05/05/ruby-1-9-encodings-a-primer-and-the-solution-for-rails/

    http://blog.grayproductions.net/articles/ruby_19s_three_default_encodings

    the short answer is you should try adding:

    # encoding: UTF-8
    

    to the top of your .rb file, and then ruby 1.9.3 should not choke on UTF chars in your code.

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

Sidebar

Related Questions

I am implementing in Ruby on Rails, and I have a view, with all
With ruby on rails, the scaffolding creates layouts for all the controllers. If I
I want regular expression in ruby on rails which remove all the html tags
first of all I'm really not really friendly with ruby or with rails, so
I'm writing a non-Rails ruby application (gasp!) and would like to be able to
Hello Ruby/Rails/Merb developers! Im currently working on a web project that will have a
This is not a ruby/rails project deploy. I have the following situation and I
I have a Ruby on Rails app that I'm working on and I'm having
I've been developing Ruby on Rails applications for some time, and have often found
I have a Rails 3 app using Ruby 1.9.2 configured to work on the

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.