Reputation: 1665
I am reading text containing emojis from a Postgres 13 database. Turns out that my Python/psycopg query does not decode/return the text as I would expect.
psql
clientWithin postgres:13
container
select description from profile WHERE id = 123
Result is as expected!
🏳️🌈 and 👩💻👩⚕️
python:3.9
containerThe result is not correctly retuned - fails to combine
>>> cur = conn.cursor()
>>> profiles = cur.fetchone()
>>> profiles[0]
🏳️\u200d🌈 and 👩\u200d💻👩\u200d⚕️
Connection object says it is using utf-8
>>> conn.info.encoding
'utf-8'
Any idea what I should be looking for?
Many thanks for your thoughts in advance, much appreciated! Eu
Upvotes: 2
Views: 322
Reputation: 9428
I have analysed string by raw bytes (provided in comment). The profiles[0]
variable holds the valid string. The problem is only in the way the string is displayed, the more advanced emojis (using ZWJ \u200d
) are not supported.
To get preview, You can dump the content to a text file and open in in a web browser.
Upvotes: 1
Reputation: 246403
The emojis consist of several characters, and the shell you are using does not know how to display them in the way you want.
JosefZ posted a link for more details: https://emojipedia.org/emoji-sequence/
Upvotes: 1