Jim Macaulay
Jim Macaulay

Reputation: 5155

Encoded values to plain text in PostgreSql

I have encoded values in the table, and wanted to select them as a plain text without altering the database property,

I have tried many ways, but not getting exact result.

Value - Er tręäńgt keinen Manteł Expected - Er treangt keinen Mantel

SELECT 'Er tręäńgt keinen Manteł', 'Er tręäńgt keinen Manteł'::bytea;
SELECT 'Er tręäńgt keinen Manteł', convert_to('Er tręäńgt keinen Manteł', 'utf-8');

Any suggestion will be helpful

Upvotes: 1

Views: 154

Answers (1)

Stefanov.sm
Stefanov.sm

Reputation: 13049

You may use the unaccent function of the unaccent extension. First create the extension (if not there already). It is included in the EDB installation package.

CREATE EXTENSION unaccent;

and then remove the diacritics

SELECT
  'Er tręäńgt keinen Manteł' as accented, 
  unaccent('Er tręäńgt keinen Manteł') as unaccented;
accented unaccented
Er tręäńgt keinen Manteł Er treangt keinen Mantel

I assume that the original character set is UTF8.

Upvotes: 2

Related Questions