Discussion:
how to get collation according to Unicode Collation Algorithm?
rudolf
2013-04-06 10:57:22 UTC
Permalink
Hi,

I have a problem with proper collation of UTF-8 strings using PostgreSQL
version 9.2.4 under Debian Linux 6.0 with de_DE.utf8 (but en_US behaves
the same) locale:

CREATE TABLE test_collation ( q text );
INSERT INTO test_collation (q) VALUES ('aa'), ('ac'), ('a&b');
SELECT * FROM test_collation ORDER BY q COLLATE "de_DE";
q
-----
aa
a&b
ac

I need the "&" character to be sorted at the beginning or at the end of
the alphabet, but it seems like it is simply ignored. The space
character (" ") is treated the same way (just swap the ampersand in
previous example with a space).

I made a test on ICU pages (http://site.icu-project.org/) and there I
get proper collation: 1. a&b, 2. aa, 3. ac. Screenshot:
Loading Image...

Is there a way to achieve this collation (note also the order of the
characters with umlaut on the screenshot) with PostgreSQL? Or is it a
glibc bug?

Thanks,

r.
--
Sent via pgsql-general mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Jasen Betts
2013-04-06 23:46:27 UTC
Permalink
Post by rudolf
Hi,
I have a problem with proper collation of UTF-8 strings using PostgreSQL
version 9.2.4 under Debian Linux 6.0 with de_DE.utf8 (but en_US behaves
CREATE TABLE test_collation ( q text );
INSERT INTO test_collation (q) VALUES ('aa'), ('ac'), ('a&b');
SELECT * FROM test_collation ORDER BY q COLLATE "de_DE";
q
-----
aa
a&b
ac
postgres uses the collation provided by libc (wccasecmp() I think)
Post by rudolf
Is there a way to achieve this collation (note also the order of the
characters with umlaut on the screenshot) with PostgreSQL? Or is it a
glibc bug?
yeah, it's a feature of glibc.
--
⚂⚃ 100% natural
--
Sent via pgsql-general mailing list (pgsql-***@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general
Continue reading on narkive:
Search results for 'how to get collation according to Unicode Collation Algorithm?' (Questions and Answers)
3
replies
How to alphabetically sort a list of words, numbers,and symbols?
started 2010-05-05 23:45:28 UTC
homework help
Loading...