def split_writable_text(encoder, text, encoding):
if not encoding:<EOL><INDENT>return None, text<EOL><DEDENT>for idx, char in enumerate(text):<EOL><INDENT>if encoder.can_encode(encoding, char):<EOL><INDENT>continue<EOL><DEDENT>return text[:idx], text[idx:]<EOL><DEDENT>return text, None<EOL>
Splits off as many characters from the begnning of text as
    are writable with "encoding". Returns a 2-tuple (writable, rest).