2

I'm struggling to save url encoded emoji as text.

I use PostgreSQL, Ruby 2.2.2, Rails 4.1.9. To encode/decode emoji I use ERB::Util module http://ruby-doc.org/stdlib-2.2.2/libdoc/erb/rdoc/ERB/Util.html

On save this

   "%F0%9F%98%80"

changes to this

   "f09f9880"

Is it connected with postgres column type (text)? Or is it rather active record connected? I'm not even sure where is the issue and solutions from other dbs or languages do not seem to make any sense in my situation.

Not really the answer for my question, but a big help in different direction would be to find a way to encode back unicode to url_encoding (so I could save it decoded and encode again before using).

     "f09f9880" => "%F0%9F%98%80"

Many thanks in advance!

Anita
  • 53
  • 8

1 Answers1

2

While I'm not sure why Postgre won't accept emojis, I can suggest that you simply encode the text as base64. This may not exactly be efficient, given that the string gets much larger, but it should solve the problem.

Fuselight
  • 554
  • 6
  • 17