Given a Unicode string and these requirements:
Check the last character of the string. If high bit set, then it is not the last byte in a UTF-8 character, so back up and try again until you find one that is.
mxlen=255
while( toolong.encode("utf8")[mxlen-1] & 0xc0 == 0xc0 ):
mxlen -= 1
truncated_string = toolong.encode("utf8")[0:mxlen].decode("utf8")