agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Shaozhong SHI <shishaozhong@gmail.com>
To: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Fault with initcap
Date: Tue, 12 Oct 2021 12:34:16 -0700
Message-ID: <10fbeda1-606a-553b-3598-eca814f40bb7@aklaver.com> (raw)
In-Reply-To: <CA+i5Jwb7gv4N9qfctixtJFEpEAdeb7yOU1zoZ-HsaQdwmbGEmg@mail.gmail.com>
References: <CA+i5JwZNEkm_geK6wSfc03D-qCaccOsW+_O2Dcc0h1VOBQfz2Q@mail.gmail.com>
	<CA+i5Jwb7gv4N9qfctixtJFEpEAdeb7yOU1zoZ-HsaQdwmbGEmg@mail.gmail.com>

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.klaver@aklaver.com





view thread (19+ messages)  latest in thread

Message-ID: <10fbeda1-606a-553b-3598-eca814f40bb7@aklaver.com>
Permalink:  ../10fbeda1-606a-553b-3598-eca814f40bb7@aklaver.com/
Also on:    postgresql.org/message-id/10fbeda1-606a-553b-3598-eca814f40bb7@aklaver.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: adrian.klaver@aklaver.com, shishaozhong@gmail.com, pgsql-general@lists.postgresql.org
  Subject: Re: Fault with initcap
  In-Reply-To: <10fbeda1-606a-553b-3598-eca814f40bb7@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox