Leave out-of-bound remove_prefix/suffix UB.
Support ostream output.

libc++'s __put_character_sequence is not used because it requires
<ostream>.  Drop the other unused libc++ special casing.