[perl #41530] s/non-utf8/is-utf8/ fails.
When the replacement is in utf8, there was failure to upgrade the result
when the source and the pattern weren't in utf8. This simply checks
that when there is a match that will lead to the replacement being done.
It then does the upgrade. If this led to changes in the source, we redo
the match because pointers to saved buffers could have changed. There
may be other cases where we don't need to redo the match, but I don't
know the code well-enough to easily figure it out.