Thread: Entering a character code in a query

Entering a character code in a query

From
John Gage
Date:
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.

Can anyone help with this problem?

Thanking you,

John

Pertinent codes:

2028 LINE SEPARATOR * may be used to represent this semantic unambiguously
U+2028, character 
‬, decimal 8232, hex 0x2028, octal \20050, binary 10000000101000 UTF-8: 0xe2 0x80 0xa8 

Re: Entering a character code in a query

From
Jasen Betts
Date:
On 2010-03-08, John Gage <jsmgage@gmail.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;