diff --git a/gv.c b/gv.c index d14eaa065519..613f3d70f4fe 100644 --- a/gv.c +++ b/gv.c @@ -2211,6 +2211,16 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, if (memEQs(name, len, "\005NCODING")) goto magicalize; break; + case '\006': + if (memEQs(name, len, "\006ORCE_UPGRADE")) { /* ${^FORCE_UPGRADE} */ + /* empty string which is marked as UTF8 on */ + SV *sv= GvSVn(gv); + sv_setpvs(sv,""); + SvUTF8_on(sv); + SvREADONLY_on(sv); + } + break; + case '\007': /* $^GLOBAL_PHASE */ if (memEQs(name, len, "\007LOBAL_PHASE")) goto ro_magicalize; diff --git a/lib/utf8.pm b/lib/utf8.pm index 823193b8c13a..9e025b3f66a2 100644 --- a/lib/utf8.pm +++ b/lib/utf8.pm @@ -5,7 +5,7 @@ use warnings; our $hint_bits = 0x00800000; -our $VERSION = '1.24'; +our $VERSION = '1.25'; our $AUTOLOAD; sub import { @@ -133,6 +133,13 @@ For example: $x =~ /ss/i; # matches my $z = uc($x); # converts to "SS" +As of 5.37.6 there is also the global variable C<${^FORCE_UPGRADE}> +which contains an empty string which when concatenated with any other +string causes the result to be an upgraded string. This can be helpful +in some contexts where explicitly calling this function might be +awkward. A similar effect can also be produced by using a C<\N{U+...}> +style escape for one of the characters in the string. + B; use L instead. diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 6a1d6da11dbc..c0b96bec940c 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -27,6 +27,11 @@ here, but most should go in the L section. [ List each enhancement as a =head2 entry ] +=head2 New global variable C<${^FORCE_UPGRADE}> + +This variable contains the empty string, and can be used to force a string +or pattern to be upgraded via concatenation. + =head1 Security XXX Any security-related notices go here. In particular, any security diff --git a/pod/perlvar.pod b/pod/perlvar.pod index e74bf4dae5ab..354843ab099b 100644 --- a/pod/perlvar.pod +++ b/pod/perlvar.pod @@ -504,6 +504,19 @@ mode is turned on. See L for the B<-a> switch. This array is package-specific, and must be declared or given a full package name if not in package main when running under C. +=item ${^FORCE_UPGRADE} + +This contains an empty string which when concatenated with any other +string will cause the result to be an upgraded string. Eg: + + print "ss"=~/\xDF/i ? "yes" : "no"; + no + +but + + print "ss"=~/\xDF${^FORCE_UPGRADE}/i ? "yes" : "no"; + yes + =item @INC X<@INC>