Ruby on Rails: serialize UTF8 issue

When I serialize a hash containing UTF8 strings, for example:

poll.variants = {0 => '',1 => '--',2 => 'test # test "'} 

in the ActiveRecord field, the resulting field contains:

 --- 0: !binary | 0YLQtdGB0YI= 1: !binary | LdGC0LXRgdGCLQ== 2: !binary | dGVzdCAjIHRlc3QgItGC0LXRgdGC 

Utf8 strings are for some reason treated as binary and base64. The mapping on the field is utf8_general_ci , and I'm a little disappointed.

Is there a way to make ActiveRecord: serialize readable barley in a field?

+4
source share
1 answer

Is there a way to make ActiveRecord: serialize a readable barcode for a field?

No. Its Base64 is encoded to encode arbitrary text (in any encoding) up to the lowest common denonimator, which is then safely sent via wire and / or stored in data warehouses that do not accept UTF-8 data.

+5
source

All Articles