Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding::CompatibilityError #23

Open
extcode opened this issue May 16, 2012 · 1 comment
Open

Encoding::CompatibilityError #23

extcode opened this issue May 16, 2012 · 1 comment

Comments

@extcode
Copy link

extcode commented May 16, 2012

I have a problem with german umlauts in secured datafields. When I saved "grün" (english: green) in a mysql database field, and show it again, i get the following Error:

Encoding::CompatibilityError in Addressees#show

incompatible character encodings: UTF8 and ASCII-8BIT

I had to use force_encode('utf8') for each field.

It this an error in strongbox? Why are the encrypted fields decrypted in ascii-8bit?

@spikex
Copy link
Owner

spikex commented May 18, 2012

The issue is how Ruby itself handles the decrypted field. "ASCII-8BIT" is an alias for "BINARY" and means "raw-bytes". Ruby chooses this because it doesn't know what the encoding of the field was before it was encrypted. So, yes you have to use force_encode to set the encoding if you need more than ASCII.

The fix would be for the Ruby RSA to use the default encoding and provide a way to override it, like Ruby IO does.

There's a good writeup on Ruby 1.9 encoding issues here:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants