Patch with three improvements to views_trim_text() attached:
Step 1: changed "/(.*)\b.+/us" to "/(.*)\p{Z}.+/us"
Current implementation of views_trim_text() has problems with special chars like German umlauts (e.g. 'Ä'): \b matches for them, so they are recognized as word boundaries, which results in "broken" words. Replacing \b with \p{Z} solves this (see http://de3.php.net/manual/en/regexp.reference.unicode.php , supported since PHP 4.4 which is OK since this is the minimum requirement for Drupal 6)
Step 2: changed "/(.*)\p{Z}.+/us" to "/(.*)\p{Z}/us"
The trailing ".+" was an unnecessary requirement because (.*) is greedy. Also a required change for step 3:
Step 3: Do not remove last word if shortened text is cut off at a word boundary
| Comment | File | Size | Author |
|---|---|---|---|
| views.module.patch | 1.28 KB | sbusch |
Comments
Comment #1
jehu commentedsubscribe
Comment #2
dawehnerIt would be cool if the comments would be above the line
it should be elseif and the { should be in the same line
Beside this code style issues it is necessary from my perspective to write a good test coverage for this function. The function does so much and can brake really fast when you change something
Comment #3
esmerel commentedNo activity on patch for more than 3 months.