Make WordPress Core

Changes between Initial Version and Version 2 of Ticket #63837


Ignore:
Timestamp:
08/19/2025 02:23:11 AM (12 months ago)
Author:
dmsnell
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #63837

    • Property Keywords has-patch has-unit-tests added
  • Ticket #63837 – Description

    initial v2  
    88
    99The last point is inherent to how the function works, but the other points can be updated by relying on the newer `wp_is_valid_utf8()` and by providing a custom fallback method to strip out invalid byte sequences.
     10
     11Improving clarity around this function involves removing the blurred line between determining if content is allegedly UTF-8 and handling it as if it is. A new function, `wp_scrub_utf8()`, can be used to produce a valid UTF-8 string formed by replacing invalid sequences of bytes with the Unicode replacement character U+FFFD (`�`). This behaves as `wp_check_invalid_bytes( $s, true )` //should// work if the `blog_charset` is `UTF-8`.
     12
     13Ideally, data should be transformed //from// some encoding //into// `UTF-8` as soon as it enters WordPress and then code which previously called `wp_check_invalid_utf8()` can now call `wp_scrub_utf8()` //if// it truly needs to remove invalid bytes.