Skip to content

Commit bc0ea08

Browse files
refactor(TeelegramBotHandler.php): using mb_string instead of strlen and substr
1 parent 4fc23dd commit bc0ea08

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
},
2929
"require": {
3030
"monolog/monolog": "^1.0|^2.0|^3.0",
31-
"ext-curl": "*"
31+
"ext-curl": "*",
32+
"ext-mbstring": "*"
3233
}
3334
}

src/TelegramBotHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ protected function write($record): void
8484

8585
private function truncateTextToTelegramLimit(string $textMessage): string
8686
{
87-
if (strlen($textMessage) <= self::TELEGRAM_MESSAGE_SIZE) {
87+
if (mb_strlen($textMessage) <= self::TELEGRAM_MESSAGE_SIZE) {
8888
return $textMessage;
8989
}
9090

91-
return substr($textMessage, 0, self::TELEGRAM_MESSAGE_SIZE);
91+
return mb_substr($textMessage, 0, self::TELEGRAM_MESSAGE_SIZE,'UTF-8');
9292
}
9393

9494
/**

0 commit comments

Comments
 (0)