class Mail::Multibyte::Chars

def rindex(needle, offset=nil)

'Café périferôl'.mb_chars.rindex(/\w/u) # => 13
'Café périferôl'.mb_chars.rindex('é') # => 6
Example:

string. Returns +nil+ if _needle_ isn't found.
codepoints, searching backward from _offset_ or the end of the
Returns the position _needle_ in the string, counting in
def rindex(needle, offset=nil)
  offset ||= length
  wrapped_offset = first(offset).wrapped_string.length
  index = @wrapped_string.rindex(needle, wrapped_offset)
  index ? (Unicode.u_unpack(@wrapped_string.slice(0...index)).size) : nil
end