Re: Entering a character code in a query

From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: Entering a character code in a query
Date: 2010-03-09 10:15:16
Message-ID: hn573k$5pt$1@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On 2010-03-08, John Gage <jsmgage(at)gmail(dot)com> wrote:
> --001636e0a62bafd12a04814c7e13
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: quoted-printable
>
> I would like to use the following query:
>
> SELECT english || '\n' || english || '\x2028' || french AS output FROM
> vocab_words_translated;
>
> where \x2028 is the hexadecimal code for a soft carriage return.
>
> However, this does not work.

you need to express it in UTF-8 or turn on standard conforming strings
and use the unicode escape syntax.

http://www.postgresql.org/docs/8.4/interactive/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-UESCAPE

> 2028 LINE SEPARATOR * may be used to represent this semantic unambiguously
> U+2028, character =E2=80=A8=E2=80=AC, decimal 8232, hex 0x2028, octal \2005=
> 0, binary
> 10000000101000 UTF-8: 0xe2 0x80 0xa8

here it it in UTF-8

SELECT english || '\n' || english || E'\xe2\x80\xa8' || french AS output FROM
vocab_words_translated;

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message venkatrao.b 2010-03-09 10:18:00 Can we overload = operator to word numeric = text
Previous Message dipti shah 2010-03-09 08:53:03 has_schema_privilege function