Re: Fault with initcap - Mailing list pgsql-general

From Lee Hachadoorian
Subject Re: Fault with initcap
Date
Msg-id CANnCtnKG20FtTKWjwr_nbNM9B6nZwxTyiqPVX_xBpd2fO71ThQ@mail.gmail.com
Whole thread Raw
In response to Re: Fault with initcap  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general


On Tue, Oct 12, 2021 at 8:28 PM Adrian Klaver <adrian.klaver@aklaver.com> wrote:

There is no function that just 'knows' that 'notemachine' is two words
and should become 'NoteMachine'.

Any chance that 'notemachine' is stored with a zero-width space (Unicode U+200B)? This is common for compound words where the programmer wants to be able to "know" that they are distinct words that are smashed together.

select initcap('notemachine'), initcap('note' || U&'\200B' || 'machine');

initcap    |initcap     |
-----------+------------+
Notemachine|NoteMachine|

You could check the length() of the string. If it is 12, there is an invisible character in there. This would explain the "unexpected" behavior that no one seems to be able to replicate.

Best,
--Lee

--
Lee Hachadoorian
Assistant Professor of Instruction, Geography and Urban Studies
Assistant Director, Professional Science Master's in GIS
Temple University

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Fault with initcap
Next
From: Simon Riggs
Date:
Subject: Re: Avg/max size of these JSON docs in Postgres