def split_utf8(s, n):
    if len(s) <= n:
        return s, None
while ord(s[n]) >= 128 and ord(s[n]) < 192:
    n -= 1
return s[0:n], s[n:]
Split unicode string into 300 byte chunks without destroying characters