Fall back to slow UTF8 algorithms that don't crash
Summary:
Fixes T5316. PCRE can blow stacks on (x|y)+ regexps, and a user is hitting a consistent fatal in PCRE.
Rewrite the fallback for phutil_is_utf8() to be iterative. This is somewhat slower, but not normally too horrible, and we have a variety of ways to mitigate that if it arises as a real issue (encourage installation of mb extension, ship a fast C extension, etc).
We already have most of this code anyway.
Test Plan: We have fairly good test coverage here already, I mostly just realigned the existing test coverage to explicitly call the new code.
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: webframp, epriestley
Maniphest Tasks: T5316
Differential Revision: https://secure.phabricator.com/D9472