a couple questions about convert()

From: smcg2297(at)frii(dot)com
To: pgsql-general(at)postgresql(dot)org
Subject: a couple questions about convert()
Date: 2014-09-18 22:35:34
Message-ID: 541B5E36.2080801@frii.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

In a postgresql-9.3.1 database with UTF8 encoding I can do:

select convert_from (E'\\x68656c6c6f', 'LATIN1');
convert_from
--------------
hello

But when I explicitly give the "to" encoding:

select convert (E'\\x68656c6c6f', 'LATIN1', 'UTF8');
convert
--------------
\x68656c6c6f

Why does that second one give different results from the first?

Second question: why is that none of the convert* functions are
marked as immutable (thus preventing me from creating a functional
index using them). Surely if I convert \x68 to utf-8 the result
will *always* be "h", won't it?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andreas 2014-09-19 01:14:51 How to run a second instance on the same server?
Previous Message Adrian Klaver 2014-09-18 21:47:04 Re: [GENERAL] [SQL] pg_multixact issues