Re: Feature request for INITCAP() function

From: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
To: "Jeff Gerbracht" <jeffgerbracht(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Feature request for INITCAP() function
Date: 2023-12-01 11:52:01
Message-ID: c7ecbe59-9a76-4e54-ae85-b0dd95c19cab@manitou-mail.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jeff Gerbracht wrote:

> It would be great if there was a way to set exceptions to the 'word'
> delimiter list used in the INITCAP() function. For example, I have
> hyphenated words like blue-green or possessives and contractions like
> don't and cat's tail
> These become Blue-Green, Don'T and Cat'S Tail.

An ICU collation may produce better results for this:

select initcap('blue-green don''t cat''s tail' COLLATE "en-x-icu");
initcap
-----------------------------
Blue-Green Don't Cat's Tail

With hyphens, it's not clear what the results should be.
Looking at the IMDb movies database [1] for instance, titles have
a mix of upper and lower case following the hyphen, even within the
same english title:

Hell-to-Pay Austin
The Co-respondent
A Pit-boy's Romance
A Cowboy's Mother-in-Law
Our Parents-In-Law
The Good-for-Nothing
When the Fire-Bells Rang
The post-millennial wave
...

[1] https://datasets.imdbws.com/

Best regards,
--
Daniel Vérité
https://postgresql.verite.pro/
Twitter: @DanielVerite

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John DeSoi 2023-12-01 14:13:20 Re: libpq crashing on macOS during connection startup
Previous Message Loles 2023-12-01 09:17:47 Re: Two started cluster on the same data directory and port