1

I'm running into a really strange phenomena after upgrading from Rails 2.3/Ruby 1.8 to Rails 3/Ruby 1.9. As I mentioned in the title, I'm using Postgres, along with the pg gem 0.10.0.

When I make a call to a model's string or text fields that contain Unicode, it works correctly, and they are returned with an encoding of UTF-8.

However, I also make use of serialized Hashes in a number of models, and whenever I make a call to read their contents (which worked perfectly prior to the upgrade), I get the following puzzling behavior:

  1. If the contents contains Unicode data, it returns as ASCII, and is displayed as escaped characters.
  2. If the contents contains ASCII data, it returns as UTF-8 (correctly), and is properly displayed.

I can simply re-encode the Unicode-returned-as-ASCII strings back to UTF-8, and everything will work fine. However, that is definitely a hack, and doesn't strike me as a good approach.

Is there a way to make serialized UTF-8 fields display correctly? If this is a bug somewhere, any idea where, and if it's known already?

William Jones
  • 18,089
  • 17
  • 63
  • 98

1 Answers1

0

Does this answer it? Why are all strings ASCII-8BIT after I upgraded to Rails 3?

Community
  • 1
  • 1
oma
  • 38,642
  • 11
  • 71
  • 99
  • Unfortunately not, I already have that on top of my files, and my issue is only affecting serialized model fields. Everything else works fine including Unicode in source files (with the magic comment at the top of the file) and ordinary model text and string fields. – William Jones Dec 22 '10 at 16:51