module Net::IMAP::StringPrep

def stringprep(string,


this specification.
The above steps MUST be performed in the order given to comply with

error. This is described in section 6.
satisfy the requirements for bidirectional strings, return an
requirements for bidirectional strings. If the string does not
any are found, make sure that the whole string satisfies the
4. Check bidi -- Possibly check for right-to-left characters, and if

section 5.
output. If any are found, return an error. This is described in
3. Prohibit -- Check for any characters that are not allowed in the

normalization. This is described in section 4.
2. Normalize -- Possibly normalize the result of step 1 using Unicode

section 3.
and, if so, replace it with its mapping. This is described in
1. Map -- For each character in the input, check if it has a mapping
>>>
def stringprep(string,
               maps:,
               normalization:,
               prohibited:,
               **opts)
  string = string.encode("UTF-8") # also dups (and raises invalid encoding)
  map_tables!(string, *maps)                     if maps
  string.unicode_normalize!(normalization)       if normalization
  check_prohibited!(string, *prohibited, **opts) if prohibited
  string
end