Subject: bug#17130: 24.4.50; Deficient Unicode case folding

From: Eli Zaretskii <[email-masked]>
Date: Sat, 29 Mar 2014 22:50:40 +0300

> From: Nathan Trapuzzano <[email-masked]>
> Cc: [email-masked]
> Date: Sat, 29 Mar 2014 14:31:52 -0400
> 
> >> If not, then what is the CANONICALIZE slot doing that couldn't be
> >> done with the regular upcase/downcase slots by themselves?
> >
> > If that slot is "trivial", i.e. contains the lower-case variant of the
> > character, then indeed this slot doesn't add information, I think,
> > only utility.  But it doesn't have to contain the lower-case variant.
> 
> I know.  But if Emacs doesn't do Unicode folding, what is there other
> than lower/upper variants?

You can make it have whatever you like, because you can set up
buffer-specific tables.

> >> Not sure I follow.  Seems to me the CANONICALIZE slot is sufficient, at
> >> least in principle.
> >
> > It is sufficient for mapping a character to its canonical equivalent,
> > but not finding the non-canonical variants of a canonical character.
> > IOW, it is not well suited to finding ς given just σ.
> 
> Finding the non-canonical variants is not something that happens (at
> least in principle) during case-insensitive matching.

The case database is not only for searching.

> > For searching, you only need the CANONICALIZE slot.  But what about
> > replacing the search string while keeping the letter case in the
> > replacement?  For that, CANONICALIZE alone is not enough, you need the
> > reverse mapping.
> 
> There is no reverse mapping when it comes to folding.  There can't be,
> since multiple characters can fold into the same character.

You can use the case of the string being replaced as guidelines.
E.g., if the replaced string was capitalized, you can capitalize the
replacement.