/
Unicode data is corrupted in textarea column with PostgreSQL

Unicode data is corrupted in textarea column with PostgreSQL

Problem

I use PostgreSQL on Windows as storage for Table Grid Editor data. Everything works fine except the case, when I try to enter any Unicode text (any national alphabet's characters) they get corrupted.

Reason

PostgreSQL uses another approach to save CLOB data. It actually encodes it to ASCII encoding configured for the database as charset setting. Sometimes this conversion corrupts the data. Unfortunately this cannot be fixed in the Table Grid Editor code because the problem lies in the PostgreSQL itself and also in the interaction of Hibernate (TGE uses it to work with the database) and PostgreSQL JDBC driver.

Workaround

Change the type of the column from 'textarea' to 'string'. It is saved correctly. But please keep in mind that 'string' column type has limited length (usually 255 characters), so long string can be truncated. To migrate your data from one column to another use existing guide: Change a string column into a textarea column.

Links

http://stackoverflow.com/questions/5043992/postgres-utf-8-clobs-with-jdbc

Related content