Skip to content

Commit a2bb782

Browse files
Merge pull request #59566 from nextcloud/bugfix/noid/fix-reverting-multibyte-strings
fix(testing): Fix fake provider reverting strings with emojis
2 parents b2fef6a + 43c5fd3 commit a2bb782

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

apps/testing/lib/Provider/FakeTranslationProvider.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ public function getAvailableLanguages(): array {
2525
}
2626

2727
public function translate(?string $fromLanguage, string $toLanguage, string $text): string {
28-
return strrev($text);
28+
return $this->mb_strrev($text);
29+
}
30+
31+
protected function mb_strrev(string $str): string {
32+
$r = '';
33+
for ($i = mb_strlen($str); $i >= 0; $i--) {
34+
$r .= mb_substr($str, $i, 1);
35+
}
36+
return $r;
2937
}
3038
}

0 commit comments

Comments
 (0)