This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add details to UTF-8 malformation error messages
authorKarl Williamson <khw@cpan.org>
Wed, 28 Sep 2016 21:05:17 +0000 (15:05 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 13 Oct 2016 17:18:11 +0000 (11:18 -0600)
commit7cf8d05d1e856f3bd3a392b3ccea008f1c1eb743
tree3387705d72ad140eb4ab6412aa70adb94afc6bb5
parent806547a7dc29226b6a06672e1d42fb136e766510
Add details to UTF-8 malformation error messages

I've long been unsatisfied with the information contained in the
error/warning messages raised when some input is malformed UTF-8, but
have been reluctant to change the text in case some one is relying on
it.  One reason that someone might be parsing the messages is that there
has been no convenient way to otherwise pin down what the exact
malformation might be.  A few commits from now will add a facility
to get the type of malformation unambiguously.  This will be a better
mechanism to use for those rare modules that need to know what's the
exact malformation.

So, I will fix and issue pull requests for any module broken by this
commit.

The messages are changed by now dumping (in \xXY format) the bytes that
make up the malformed character, and extra details are added in most
cases.

Messages about overlongs now display the code point they evaluate to and
what the shortest UTF-8 sequence for generating that code point is.

Messages about overflowing now just display that it overflows, since the
entire byte sequence is now dumped.  The previous message displayed just
the byte which was being processed where overflow was detected, but that
information is not at all meaningfull.
12 files changed:
embed.fnc
embed.h
ext/XS-APItest/t/utf8.t
lib/utf8.t
pod/perldelta.pod
pod/perldiag.pod
proto.h
t/io/utf8.t
t/lib/warnings/utf8
t/op/pack.t
t/op/utf8decode.t
utf8.c