'\n    >>> us = u"\u30a6\u30a3\u30ad\u30da\u30c7\u30a3\u30a2\u306b\u3088\u3046\u3053\u305d"\n    >>> s = us.encode("UTF-8")\n    >>> trunc20 = truncate_utf8(s, 20)\n    >>> print trunc20.decode("UTF-8")\n    \u30a6\u30a3\u30ad\u30da\u30c7\u30a3\n    >>> len(trunc20)\n    18\n    >>> trunc21 = truncate_utf8(s, 21)\n    >>> print trunc21.decode("UTF-8")\n    \u30a6\u30a3\u30ad\u30da\u30c7\u30a3\u30a2\n    >>> len(trunc21)\n    21\n    '
Truncating unicode so it fits a maximum size when encoded for wire transfer