pub fn preserve_case(
matched: &str,
replacement: &str,
locale: FoldLocale,
) -> StringExpand description
Dress replacement in the case of the text it is replacing.
A reviewed rename hits Aurélien, AURÉLIEN and aurélien in the same manuscript, and
the writer means one rename, not three.
Exactly three shapes are recognised, and everything else is left verbatim. That last
part is the important one: this function guesses at what a writer meant, and a guess it is
not sure about must not be written into their book. McDonald, iPhone, eBay are
deliberately not “initial capital” — they are their own thing, and the replacement the
caller supplied is a better answer than anything inferred from them.
§ALL CAPS needs two letters
A single capital is not shouting. O, K, É are all-uppercase by inspection and
titlecase by intent, and treating them as SHOUTING turns a rename of a one-letter name
into ELENA where the prose wanted Elena — silently, at every occurrence, in someone’s
manuscript. There is no way to tell the two apart from one letter, so the tie goes to the
quieter answer.
§Locale
In Turkish the uppercase of i is İ, not I. A case-preserver blind to that would
rewrite Turkish prose into a different word — the same class of silent corruption as
folding the dotless ı onto i.