Hi, All<br><br>I have an encountered an issue where the args field is not saved correctly to the database.  I encounter an error like this:<br><br>ActiveRecord::StatementInvalid (RuntimeError: ERROR    C22021    M invalid byte sequence for encoding &quot;UTF8&quot;: 0xcb3a    H This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by &quot;client_encoding&quot;.    <br>
<br>Here&#39;s the SQL that gets send to the database (note that the dump-ed args are written as a string):   <br><br>F.\src\backend\utils\mb\wchar.c    L1545    Rreport_invalid_encoding: INSERT INTO &quot;bdrb_job_queues&quot; (&quot;args&quot;, &quot;job_key&quot;, &quot;taken&quot;, &quot;worker_key&quot;, &quot;worker_method&quot;, &quot;priority&quot;, &quot;finished_at&quot;, &quot;tag&quot;, &quot;worker_name&quot;, &quot;timeout&quot;, &quot;submitted_at&quot;, &quot;finished&quot;, &quot;runner_info&quot;, &quot;submitter_info&quot;, &quot;archived_at&quot;, &quot;scheduled_at&quot;, &quot;started_at&quot;) VALUES(E&#39;{: car_idiĖ:inspection_report_name&quot;First week inspection&#39;, E&#39;66&#39;, 0, E&#39;&#39;, E&#39;send_warranty_notice&#39;, NULL, NULL, NULL, E&#39;notification_worker&#39;, NULL, &#39;2009-03-27 03:53:14.036000&#39;, 0, NULL, NULL, NULL, &#39;2009-04-03 03:53:13.917000&#39;, NULL) RETURNING &quot;id&quot;):<br>
<br>This won&#39;t happen all the time ... only when the array of bytes from the dump (represented as a string) have combinations or bytes that can&#39;t be interpreted as UTF8.<br><br>This could be fixed in a couple of ways I suppose the most obvious being how the adapter saves bytea fields and encoding the dump as UTF8 ... but I wasn&#39;t sure if it would un-encode.  So I implemented the fool proof option of Base64 encoding the data, which means never having to worry about encoding again (because this is not the first time I&#39;ve had a character encoding issue)<br>
<br>Here&#39;s the bulletproof hack that I added to my BdrbJobQueue<br><br>...<br>  #these accessors get around any possible character encoding issues with the database<br>  def args=(args)<br>    write_attribute(:args, Base64.b64encode(args))<br>
  end<br>  def args<br>    Base64.decode64(read_attribute(:args))<br>  end<br>...<br><br>Hope that helps someone.  It will help anyone who has the problem referred to here <a href="http://rubyforge.org/pipermail/backgroundrb-devel/2009-March/002325.html">http://rubyforge.org/pipermail/backgroundrb-devel/2009-March/002325.html</a>.  Note, to the best of my knowledge all my other UTF8 settings are correct.<br>
<br>Cheers<br>Justin<br><br><br>