String#truncate_bytes by jeremy · Pull Request #27319 · rails/rails

Limit to N bytes without breaking multibytes chars. Can be done with foo.mb_chars.limit(n.bytes), but that's much slower. This joins our #truncate and #truncate_words family.