'How to convert iso 8859 string to UTF8 in a postgresql 12 database?
EDIT :
I think I was not clear, I am sorry for that : I have a column with bytea data. This column, when I apply encode(column,'escape') to it, I got text in the iso8859-1 encoding. I would like to change this text to UTF-8 encoding.
However, when I use the convert function :
SELECT convert(encode(column,'escape'),'LATIN1','UTF8') FROM table
I got the error : function convert(text, unknown, unknown) does not exist.
I am currently stuck at this point.
Previous question : When I call convert(encode(column,'escape' When I do:
select encode(name_of_column, 'escape')
from my_table;
I get a varchar encoded in iso88591 instead of UTF-8. I use Postgresql 12. I cannot find a convert function like Oracle convert function for this Postgresql version.
Does anyone know how to deal with this issue?
Solution 1:[1]
As iso8859-1 is also called Latin 1, you can use convert
SELECT convert( 'text_in_Latin 1 or so8859-1 ', 'LATIN1','UTF8')| convert | | :--------------------------------------------------------- | | \x746578745f696e5f4c6174696e2031206f7220736f383835392d3120 |
db<>fiddle here
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Laurenz Albe |
