# Pastebin 49ZTdkRy if _size > 0 then let chars = Array[U32](s.size()) var i = _size - 1 var truncate_at = _size for rune in s.runes() do chars.push(rune) end repeat try match utf32(i.isize())? | (0xFFFD, 1) => None | (let c: U32, _) => if not chars.contains(c) then break end truncate_at = i end else break end until (i = i - 1) == 0 end truncate(truncate_at) end