Re: Initcap works differently with different locale providers
Oleg Tselebrovskiy <o.tselebrovskiy@postgrespro.ru>
From: Oleg Tselebrovskiy <o.tselebrovskiy@postgrespro.ru>
To: Jeff Davis <pgsql@j-davis.com>
Cc: Alexander Korotkov <aekorotkov@gmail.com>,
pgsql-docs@lists.postgresql.org
Date: 2025-08-04T05:30:57Z
Lists: pgsql-docs
Attachments
- v2-0001-initcap-documentation.patch (text/x-diff) patch v2-0001
- v2-0002-initcap-documentation.patch (text/x-diff) patch v2-0002
Jeff Davis wrote at 2025-07-31 02:58: Apologies for the late answer to a review > First, it doesn't mention the "builtin" provider, which uses the same > word break rules as libc. Completely forgot about builtin provider in the first patch, my bad > Second, word boundaries can be complex, and I'm wondering if we should > not be so precise about what ICU does or doesn't do. For instance, ICU > has options like U_TITLECASE_ADJUST_TO_CASED, > U_TITLECASE_NO_BREAK_ADJUSTMENT, etc., and I'm not sure exactly > which one of those we use. While [1] describes the default word boundary rules and could be useful as a starting point, I agree that in reality it probably is more complicated. I didn't exactly find any place where U_TITLECASE_ADJUST_TO_CASED and alike are set in non-test code, but U_TITLECASE_ADJUST_TO_CASED was used as a default prior to ICU 60, so initcap() will also behave differently depending on ICU version > I'd prefer that we try to explain that INITCAP() is intended for > convenient display, and the specific result should not be relied upon > (at least for ICU; maybe for all providers). If you want specific word > boundary rules, write your own function. First patch just adds this warning about not relying on initcap() exact result. The second one is the same, but removes the part "what is a word" since it's could be moot because we recommend writing custom functions, so understanding what is a word is not exactly needed. Still on the fence about which patch is better, though Thoughts? [1]: https://www.unicode.org/reports/tr29/#Word_Boundaries Regards, Oleg Tselebrovskiy
Commits
-
Further clarify documentation for the initcap function
- f8ce9ed220b5 19 (unreleased) landed
-
Revert "Clarify documentation for the initcap function"
- 0edaaa8f2978 14.19 landed
- 06633271ec40 13.22 landed
- 098c27dee4c1 15.14 landed
- b862465dba33 16.10 landed
- 3b3aa1f651c7 17.6 landed
- 2ae8280d16c9 18.0 landed
-
Clarify documentation for the initcap function
- 907ac2ca30bb 13.22 landed
- 276b022ec05b 14.19 landed
- 9af075c4e27e 15.14 landed
- d861b9282261 16.10 landed
- 3c05d4d3433e 17.6 landed
- 1fe9e3822c4e 18.0 landed
- c2c2c7e22566 19 (unreleased) landed