Enhance Str::limit() and str_limit() with an option to preserve words

This replaces pull request replaces #3517.

In this pull request I've fixed the coding style, extended parameters for related helper str_limit() and squashed all commits.

Discussion: #3515