Code4R7
Code4R7

Reputation: 2958

How to transcode Unicode to ISO 8859-1 with postgres 13

How can I transcode a UTF-8 string to Latin1 with PostgreSQL 13+ ?

I've read this SO thread but the functions convert(), convert_from() and convert_to() no longer exist starting from Postgres 13.

EDIT: the solution is given by Laurenz Albe, who pointed out that the functions still exist. I was only afterwards that I noticed:

So the correct SQL should have been:

SELECT convert('text_in_utf8', 'UTF8', 'LATIN1');

Upvotes: 0

Views: 778

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 247270

convert_from and convert_to still exist, but they cannot convert from text to text because text is always a string in the database encoding. Strings in other encoding can only be stored as bytea.

I cannot guide you any further, because you didn't tell us what problem you are trying to solve.

Upvotes: 1

Related Questions