1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Support casing characters which map into multiple code points (bug#24603)

Implement unconditional special casing rules defined in Unicode standard.

Among other things, they deal with cases when a single code point is
replaced by multiple ones because single character does not exist (e.g.
‘fi’ ligature turning into ‘FL’) or is not commonly used (e.g. ß turning
into SS).

* admin/unidata/SpecialCasing.txt: New data file pulled from Unicode
standard distribution.
* admin/unidata/README: Mention SpecialCasing.txt.

* admin/unidata/unidata-get.el (unidata-gen-table-special-casing,
unidata-gen-table-special-casing--do-load): New functions generating
‘special-uppercase’, ‘special-lowercase’ and ‘special-titlecase’
character Unicode properties built from the SpecialCasing.txt Unicode
data file.

* src/casefiddle.c (struct casing_str_buf): New structure for
representing short strings used to handle one-to-many character
mappings.

(case_character_imlp): New function which can handle one-to-many
character mappings.
(case_character, case_single_character): Wrappers for the above
functions.  The former may map one character to multiple (or no)
code points while the latter does what the former used to do (i.e.
handles one-to-one mappings only).

(do_casify_natnum, do_casify_unibyte_string,
do_casify_unibyte_region): Use case_single_character.
(do_casify_multibyte_string, do_casify_multibyte_region): Support new
features of case_character.
* (do_casify_region): Updated to reflact do_casify_multibyte_string
changes.

(casify_word): Handle situation when one character-length of a word
can change affecting where end of the word is.

(upcase, capitalize, upcase-initials): Update documentation to mention
limitations when working on characters.

* test/src/casefiddle-tests.el (casefiddle-tests-char-properties):
Add test cases for the newly introduced character properties.
(casefiddle-tests-casing): Update test cases which are now passing.

* test/lisp/char-fold-tests.el (char-fold--ascii-upcase,
char-fold--ascii-downcase): New functions which behave like old ‘upcase’
and ‘downcase’.
(char-fold--test-match-exactly): Use the new functions.  This is needed
because otherwise fi and similar characters are turned into their multi-
-character representation.

* doc/lispref/strings.texi: Describe issue with casing characters versus
strings.
* doc/lispref/nonascii.texi: Describe the new character properties.
This commit is contained in:
Michal Nazarewicz 2016-10-05 00:06:01 +02:00
parent 2c87dabd04
commit b3b9b258c4
9 changed files with 679 additions and 128 deletions

View file

@ -619,6 +619,29 @@ Corresponds to the Unicode @code{Simple_Titlecase_Mapping} property.
character of a word needs to be capitalized. The value of this
property is a single character. For unassigned codepoints, the value
is @code{nil}, which means the character itself.
@item special-uppercase
Corresponds to Unicode language- and context-independent special upper-casing
rules. The value of this property is a string (which may be empty). For
example mapping for @code{U+00DF} (@sc{latin small letter sharp s}) is
@code{"SS"}. For characters with no special mapping, the value is @code{nil}
which means @code{uppercase} property needs to be consulted instead.
@item special-lowercase
Corresponds to Unicode language- and context-independent special lower-casing
rules. The value of this property is a string (which may be empty). For
example mapping for @code{U+0130} (@sc{latin capital letter i with dot above})
the value is @code{"i\u0307"} (i.e. 2-character string consisting of @sc{latin
small letter i} followed by @sc{combining dot above}). For characters with no
special mapping, the value is @code{nil} which means @code{lowercase} property
needs to be consulted instead.
@item special-titlecase
Corresponds to Unicode unconditional special title-casing rules. The value of
this property is a string (which may be empty). For example mapping for
@code{U+FB01} (@sc{latin small ligature fi}) the value is @code{"Fi"}. For
characters with no special mapping, the value is @code{nil} which means
@code{titlecase} property needs to be consulted instead.
@end table
@defun get-char-code-property char propname