def foldOneLine(outbuf, input, lineLength=75):
    """
    Folding line procedure that ensures multi-byte utf-8 sequences are not broken across lines

    TO-DO: This all seems odd. Is it still needed, especially in python3?
    """
    if len(input) < lineLength:
        try:
            outbuf.write(bytes(input, 'UTF-8'))
        except Exception:
            outbuf.write(input)
    else:
        start = 0
        written = 0
        while written < len(input):
            offset = start + lineLength - 1
            if offset >= len(input):
                line = input[start:]
                try:
                    outbuf.write(bytes(line, 'UTF-8'))
                except Exception:
                    outbuf.write(line)
                written = len(input)
            else:
                line = input[start:offset]
                try:
                    outbuf.write(bytes(line, 'UTF-8'))
                    outbuf.write(bytes('\r\n ', 'UTF-8'))
                except Exception:
                    outbuf.write(line)
                    outbuf.write('\r\n ')
                written += offset - start
                start = offset
    try:
        outbuf.write(bytes('\r\n', 'UTF-8'))
    except Exception:
        outbuf.write('\r\n')
