Even now that http://api.drupal.org/api/function/truncate_utf8/6 truncates to a specified number of characters instead of bytes (http://drupal.org/node/200185), http://api.drupal.org/api/function/node_teaser/6 can still return a string shorter than it is supposed to.
Simple fix: change
// If we have a short body, the entire body is the teaser.
if (strlen($body) <= $size) {
return $body;
}
to
// If we have a short body, the entire body is the teaser.
if (drupal_strlen($body) <= $size) {
return $body;
}
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | node_teaser_utf8.patch | 515 bytes | pancho |
Comments
Comment #1
panchoYep, that was an easy fix. Works now as advertised.
Comment #2
gpk commentedWorks fine. Used this sample code:
Before the patch, the output is
10, 15
éêëìí.
After the patch it is
10, 15
éêëìí. Hi.
Tested with other values of $size also.
Comment #3
gábor hojtsyThanks, committed.
Comment #4
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.