Text got cut off when strange chars inside when trying to save into TEXT field
<p>Having a text like that in a file. I want to insert that text in my database (UTF8 encoding by the way).</p>

<pre><code>OK:     "Spanning op P4V2 (TP2)" : 4.00 V DC &lt;= 4.20 V DC
OK:     "Spanning op P1V8_EHSX_BGS2 (TP1030)" : 1.81 V DC &gt;= 1.71 V DC
OK:     "Spanning op P1V8_EHSX_BGS2 (TP1030)" : 1.81 V DC &lt;= 1.89 V DC
LOG:    Waiting for barebox command prompt
LOG:    ^@^@Starting Bootlets...
LOG:
LOG:    Configured for DCDC_BATT only power source.
LOG:    Initialized 1 ram bank(s)
LOG:    Starting secondary bootloader
</code></pre>

<p>The table has a field "results" with type "TEXT". However the file get cut off when finds the "^@" characters. Everything after that is not saved in my database.</p>

<p>I have tried many things like:</p>

<pre><code>results = results.encode('utf-8')
self.db.set_client_encoding('UTF8')
c.execute("INSERT INTO ats2_testrun (serial_number_id, test_system_id, date, status_ok, results, author, svn_url, svn_revision_number, service_report_id)  +
                  "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s);",(sid, tsid, tstamp, ok, results, author, svn_url, svn_revision_number, service_report_id))
</code></pre>

<p>But it doesn't work. Somebody told me to transform that field into a binary one, but if there is a way to save that into a TEXT field. I don't care the strange chars "^@" so they can be removed.</p>

<p><code>0x00</code> (<code>^@</code>) is a string terminator. It is the only character you can not save in a 0x00-terminated field (which TEXT is).</p>

<p>Replace the chars and you will be just fine.</p>

python postgresql unicode utf-8 psycopg2