protected function replace_invalid_with_pct_encoding($text, $extra_chars, $iprivate = false) {
        // Normalize as many pct-encoded sections as possible
        $text = preg_replace_callback('/(?:%[A-Fa-f0-9]{2})+/', array($this, 'remove_iunreserved_percent_encoded'), $text);

        // Replace invalid percent characters