On Thu, 2023-10-26 at 16:49 +0200, Peter Eisentraut wrote: > On 25.10.23 20:32, Jeff Davis wrote: > > But what should the result of UPPER('á' COLLATE UCS_BASIC) be? In > > Postgres, the answer is 'á', but intuitively, one could reasonably > > expect the answer to be 'Á'. > > I think that's right. But what would you put into ctype to make that > happen?
It looks like using Unicode files to implement upper()/lower()/initcap() behavior would not be very hard. The Default Case Algorithm only needs a simple mapping for toUppercase() and toLowercase(). Our initcap() is not defined in the standard, and we document that it only differentiates between alphanumeric and non-alphanumeric characters, so we could get that behavior pretty easily as well. If we wanted to do it the Unicode way instead, we can follow the toTitlecase() part of the Default Case Algorithm, which is based on word breaks and would require another lookup table for that. I've already posted a patch that includes a lookup table for the General Category, so that could be used for the rest of the ctype behavior. Doing ctype based on built-in Unicode tables would be a good use case for the "builtin" provider that I had previously proposed. > The standard doesn't have the notion of locale-dependent case > conversion. That explains it. Interesting. Regards, Jeff Davis