Page MenuHomePhorge

D25092.1736695631.diff
No OneTemporary

D25092.1736695631.diff

diff --git a/src/utils/utf8.php b/src/utils/utf8.php
--- a/src/utils/utf8.php
+++ b/src/utils/utf8.php
@@ -289,8 +289,21 @@
*/
function phutil_utf8_strlen($string) {
if (function_exists('utf8_decode')) {
- return strlen(utf8_decode($string));
- }
+ // Historically, this was just a call to strlen(utf8_decode($string))
+ // but, since PHP 8.2, that function is deprecated, so this is
+ // the current equivalent.
+ // Note that we cannot just adopt mb_strlen($string, 'ISO-8859-1')
+ // since it's not the exact equivalent as far as we can see.
+ // https://we.phorge.it/T15188
+ return strlen(mb_convert_encoding($string, 'ISO-8859-1'));
+ }
+
+ // TODO: Eventually drop the next function call, since it was
+ // probably just a backward compatibility hack for the lack
+ // of utf8_decode() that - in any case - we should not use it.
+ // Note that - in any case - this replacement probably works since PHP 4:
+ // strlen( mb_convert_encoding($string, 'ISO-8859-1') )
+ // So it's really probably the case to just drop this case.
return count(phutil_utf8v($string));
}

File Metadata

Mime Type
text/plain
Expires
Sun, Jan 12, 15:27 (6 d, 9 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1112636
Default Alt Text
D25092.1736695631.diff (1 KB)

Event Timeline