Entering a character code in a query

Started by John Gageabout 16 years ago3 messagesgeneral
Jump to latest
#1John Gage
jsmgage@numericable.fr

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

#2Laurenz Albe
laurenz.albe@cybertec.at
In reply to: John Gage (#1)
Re: Entering a character code in a query

John Gage wrote:

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?

If you have PostgreSQL 8.4 with standard_conforming_strings = on,
you could write:

english || E'\n' || english || U&'\2028' || french

Otherwise, you have to resort to

english || E'\n' || english || chr(8232) || french

(provided your server_encoding is UTF8).

Yours,
Laurenz Albe

#3John Gage
jsmgage@gmail.com
In reply to: Laurenz Albe (#2)
Re: Entering a character code in a query

I would just like to thank Albe and Jasen for their responses. What an
extraordinary environment Postgres is! Human and computing.

On Tue, Mar 9, 2010 at 1:32 PM, Albe Laurenz <laurenz.albe@wien.gv.at>wrote:

Show quoted text

John Gage wrote:

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?

If you have PostgreSQL 8.4 with standard_conforming_strings = on,
you could write:

english || E'\n' || english || U&'\2028' || french

Otherwise, you have to resort to

english || E'\n' || english || chr(8232) || french

(provided your server_encoding is UTF8).

Yours,
Laurenz Albe

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general