This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Extend UTF-EBCDIC to handle up to 2**64-1
authorKarl Williamson <khw@cpan.org>
Thu, 19 Nov 2015 04:28:14 +0000 (21:28 -0700)
committerKarl Williamson <khw@cpan.org>
Wed, 25 Nov 2015 22:48:17 +0000 (15:48 -0700)
commitc0236afee0c5845d3823612c5cd34eccc4d29321
tree61f9694bcd4579ccd2196c74ec7be8c69cda1f0f
parentb67fd2c557cdf9bdc899813a5e4f2dee22e4f63e
Extend UTF-EBCDIC to handle up to 2**64-1

This uses for UTF-EBCDIC essentially the same mechanism that Perl
already uses for UTF-8 on ASCII platforms to extend it beyond what might
be its natural maximum.  That is, when the UTF-8 start byte is 0xFF, it
adds a bunch more bytes to the character than it otherwise would,
bringing it to a total of 14 for UTF-EBCDIC.  This is enough to handle
any code point that fits in a 64 bit word.

The downside of this is that this extension is not compatible with
previous perls for the range 2**30 up through the previous max,
2**30 - 1.  A simple program could be written to convert files that were
written out using an older perl so that they can be read with newer
perls, and the perldelta says we will do this should anyone ask.
However, I strongly suspect that the number of such files in existence
is zero, as people in EBCDIC land don't seem to use Unicode much, and
these are very large code points, which are associated with a
portability warning every time they are output in some way.

This extension brings UTF-EBCDIC to parity with UTF-8, so that both can
cover a 64-bit word.  It allows some removal of special cases for EBCDIC
in core code and core tests.  And it is a necessary step to handle Perl
6's NFG, which I'd like eventually to bring to Perl 5.

This commit causes two implementations of a macro in utf8.h and
utfebcdic.h to become the same, and both are moved to a single one in
the portion of utf8.h common to both.

To illustrate, the I8 for U+3FFFFFFF (2**30-1) is
"\xFE\xBF\xBF\xBF\xBF\xBF\xBF" before and after this commit, but the I8
for the next code point, U+40000000 is now
"\xFF\xA0\xA0\xA0\xA0\xA0\xA0\xA1\xA0\xA0\xA0\xA0\xA0\xA0",
and before this commit it was "\xFF\xA0\xA0\xA0\xA0\xA0\xA0".

The I8 for 2**64-1 (U+FFFFFFFFFFFFFFFF) is
"\xFF\xAF\xBF\xBF\xBF\xBF\xBF\xBF\xBF\xBF\xBF\xBF\xBF\xBF", whereas
before this commit it was unrepresentable.

Commit 7c560c3beefbb9946463c9f7b946a13f02f319d8 said in its message that
it was moving something that hadn't been needed on EBCDIC until the
"next commit".  That statement turned out to be wrong, overtaken by
events.  This now is the commit it was referring to.
commit I prematurely
pushed that
22 files changed:
autodoc.pl
charclass_invlists.h
ebcdic_tables.h
ext/XS-APItest/t/utf8.t
pod/perldelta.pod
pod/perldiag.pod
pod/perlebcdic.pod
pod/perlport.pod
pod/perlunicode.pod
regcharclass.h
regen/charset_translations.pl
regen/ebcdic.pl
t/lib/warnings/utf8
t/op/bop.t
t/op/chop.t
t/op/index.t
t/op/ver.t
t/re/pat_advanced.t
toke.c
utf8.c
utf8.h
utfebcdic.h