mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
* enc/unicode/case-folding.rb, casefold.h: Data generation to implement
swapcase functionality for titlecase characters. Swapcase isn't defined by Unicode, because the purpose/usage of swapcase is unclear anyway. The implementation follows a proposal from Nobu, swaping the case of each component of a titlecase character individually. This means that the titlecase characters have to be decomposed. * enc/unicode.c: Code using the above data. * test/ruby/enc/test_case_mapping.rb: Tests for the above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
69d6e315b5
commit
5e9d33ad49
5 changed files with 192 additions and 150 deletions
|
@ -139,7 +139,7 @@ code3_equal(const OnigCodePoint *x, const OnigCodePoint *y)
|
|||
|
||||
/* macros related to ONIGENC_CASE flags */
|
||||
/* defined here because not used in other files */
|
||||
#define ONIGENC_CASE_SPECIALS (ONIGENC_CASE_TITLECASE|ONIGENC_CASE_UP_SPECIAL|ONIGENC_CASE_DOWN_SPECIAL)
|
||||
#define ONIGENC_CASE_SPECIALS (ONIGENC_CASE_TITLECASE|ONIGENC_CASE_IS_TITLECASE|ONIGENC_CASE_UP_SPECIAL|ONIGENC_CASE_DOWN_SPECIAL)
|
||||
|
||||
/* macros for length in CaseMappingSpecials array in enc/unicode/casefold.h */
|
||||
#define SpecialsLengthOffset 25 /* needs to be higher than the 22 bits used for Unicode codepoints */
|
||||
|
@ -715,6 +715,13 @@ onigenc_unicode_case_map(OnigCaseFoldType* flagP,
|
|||
if (flags&OnigCaseFoldFlags(folded->n)&ONIGENC_CASE_SPECIALS) { /* special */
|
||||
OnigCodePoint *SpecialsStart = CaseMappingSpecials + OnigSpecialIndexDecode(folded->n);
|
||||
|
||||
if (OnigCaseFoldFlags(folded->n)&ONIGENC_CASE_IS_TITLECASE) { /* swapCASE available */
|
||||
if ((flags&(ONIGENC_CASE_UPCASE|ONIGENC_CASE_DOWNCASE))
|
||||
== (ONIGENC_CASE_UPCASE|ONIGENC_CASE_DOWNCASE)) /* swapCASE needed */
|
||||
goto SpecialsCopy;
|
||||
else /* swapCASE not needed */
|
||||
SpecialsStart += SpecialsLengthExtract(*SpecialsStart);
|
||||
}
|
||||
if (OnigCaseFoldFlags(folded->n)&ONIGENC_CASE_TITLECASE) { /* Titlecase available */
|
||||
if (flags&ONIGENC_CASE_TITLECASE) /* Titlecase needed, but not yet Titlecase */
|
||||
goto SpecialsCopy;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue