Page MenuHomePhorge

D25092.1734637523.diff
No OneTemporary

D25092.1734637523.diff

diff --git a/src/utils/utf8.php b/src/utils/utf8.php
--- a/src/utils/utf8.php
+++ b/src/utils/utf8.php
@@ -288,8 +288,14 @@
* @return int The character length of the string.
*/
function phutil_utf8_strlen($string) {
- if (function_exists('utf8_decode')) {
- return strlen(utf8_decode($string));
+ if (function_exists('mb_convert_encoding')) {
+ // 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'));
}
return count(phutil_utf8v($string));
}

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 19:45 (21 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1015447
Default Alt Text
D25092.1734637523.diff (817 B)

Event Timeline