Re: Fault with initcap

From: Lee Hachadoorian <Lee(dot)Hachadoorian+L(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: 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-13 03:55:08
Message-ID: CANnCtnKG20FtTKWjwr_nbNM9B6nZwxTyiqPVX_xBpd2fO71ThQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

On Tue, Oct 12, 2021 at 8:28 PM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Metin Ulusinan 2021-10-13 06:33:43 Re: Fault with initcap
Previous Message Adrian Klaver 2021-10-13 00:27:51 Re: Fault with initcap

Browse pgsql-sql by date

  From Date Subject
Next Message Metin Ulusinan 2021-10-13 06:33:43 Re: Fault with initcap
Previous Message Adrian Klaver 2021-10-13 00:27:51 Re: Fault with initcap