Skip to content

Commit

Permalink
Fixes #4: support multibytes string split
Browse files Browse the repository at this point in the history
Requires php extension mbstring:
  • Loading branch information
ArthurHoaro committed Jan 20, 2017
1 parent 1a68fc0 commit 1f3c3cf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ to post it on Twitter.

- PHP 5.3
- PHP cURL extension
- PHP mbstring extension
- Shaarli >= v0.8.1

## Installation
Expand Down
2 changes: 1 addition & 1 deletion shaarli2twitter/shaarli2twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function replace_placeholder($tweet, $placeholder, $value)
// Tweets URL have a fixed size due to t.co
$valueLength = ($placeholder != 'url' && $placeholder != 'permalink') ? strlen($value) : TWEET_URL_LENGTH;
if ($current + $valueLength > TWEET_LENGTH) {
$value = substr($value, 0, TWEET_LENGTH - $current - 3) . '';
$value = mb_strcut($value, 0, TWEET_LENGTH - $current - 3) . '';
}
return str_replace('${'. $placeholder .'}', $value, $tweet);
}
Expand Down

0 comments on commit 1f3c3cf

Please sign in to comment.