HomePhabricator

Remove call to PHP "utf8_decode()" in "phutil_utf8_strlen()"

Description

Remove call to PHP "utf8_decode()" in "phutil_utf8_strlen()"

Summary:
Ref T13588. See PHI2228. Under PHP8.2 and newer, calls to "utf8_decode()" raise a deprecation warning.

The behavior of this function probably isn't great under any PHP version since it UTF8 space into ISO-8859-1 space, which isn't an operation you can really implement "correctly" in the general case. For the specific narrow case of counting characters, as here, you could probably do worse, but I think the PHP upstream's deprecation of this function is entirely reasonable.

The fallback implementation for strlen, "phutil_utf8v()", should produce the correct result in all cases. The downside is that it's runtime UTF8 parsing, which may be slow. This function is called rarely and I don't think this will present a problem, but if it does I'd rather address it once it arises.

Test Plan: Under PHP8.2, ran "arc lint". After patch, no longer saw deprecation warning.

Maniphest Tasks: T13588

Differential Revision: https://secure.phabricator.com/D21857

Details