Re: Fault with initcap

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Shaozhong SHI <shishaozhong(at)gmail(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Fault with initcap
Date: 2021-10-12 19:34:16
Message-ID: 10fbeda1-606a-553b-3598-eca814f40bb7@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

On 10/12/21 09:31, Shaozhong SHI wrote:
> I tried initcap and found a major problem with it.

What Postgres version?

In version 12 and 14 I get:

>
> Initcap of notemachine is NoteMachine.

select initcap('notemachine');
initcap
-------------
Notemachine

>
> Initcap of Sainsbury's Bank is Sainsbury'S bank.

select initcap('Sainsbury''s Bank');
initcap
------------------
Sainsbury'S Bank

Which follows the definition here:

https://www.postgresql.org/docs/14/functions-string.html

initcap ( text ) → text

Converts the first letter of each word to upper case and the rest to
lower case. Words are sequences of alphanumeric characters separated by
non-alphanumeric characters.

>
> This is not expected.

What is the encoding, collate, ctype for the database?

Can be found in psql using:

\l db_name

>
> Anyway to get around this problem?
>
> Regards,
>
> David

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Karsten Hilbert 2021-10-12 19:56:57 Aw: Re: Re: Fault with initcap
Previous Message Michael Lewis 2021-10-12 19:21:18 Re: Avg/max size of these JSON docs in Postgres

Browse pgsql-sql by date

  From Date Subject
Next Message JP 2021-10-12 19:44:07 Re: Removing JSONB key across all elements of nested array
Previous Message Karsten Hilbert 2021-10-12 17:52:56 Aw: Re: Fault with initcap