parameters: (s, length)
return_statement: return s
docstring: Truncates a string to a given number of bytes when encoded as UTF-8.
  
    Ensures the given string does not take more than length bytes when encoded
    as UTF-8. Adds trailing ellipsis (...) if truncation occurred. A truncated
    string may end up encoding to a length slightly shorter than length because
    only whole Unicode codepoints are dropped.
  
    Args:
      s: The string to truncate.
      length: the length (in bytes) to truncate to.
docstring_summary: Truncates a string to a given number of bytes when encoded as UTF-8.
docstring_tokens: Truncates a string to a given number of bytes when encoded as UTF - 8 .
function: def _TruncateToUTF8Bytes(s, length):
    """ Truncates a string to a given number of bytes when encoded as UTF-8.
  
    Ensures the given string does not take more than length bytes when encoded
    as UTF-8. Adds trailing ellipsis (...) if truncation occurred. A truncated
    string may end up encoding to a length slightly shorter than length because
    only whole Unicode codepoints are dropped.
  
    Args:
      s: The string to truncate.
      length: the length (in bytes) to truncate to.
    """
    try:
      encoded = s.encode('utf-8')
    # When encode throws UnicodeDecodeError in py2, it usually means the str is
    # already encoded and has non-ascii chars. So skip re-encoding it.
    except UnicodeDecodeError:
      encoded = s
    if len(encoded) > length:
      # Truncate, leaving space for trailing ellipsis (...).
      encoded = encoded[:length - 3]
      # Truncating the string encoded as UTF-8 may have left the final codepoint
      # only partially present. Pass 'ignore' to acknowledge and ensure this is
      # dropped.
      return encoded.decode('utf-8', 'ignore') + "..."
    return s
function_tokens: def _TruncateToUTF8Bytes ( s , length ) : try : encoded = s . encode ( 'utf-8' ) # When encode throws UnicodeDecodeError in py2, it usually means the str is # already encoded and has non-ascii chars. So skip re-encoding it. except UnicodeDecodeError : encoded = s if len ( encoded ) > length : # Truncate, leaving space for trailing ellipsis (...). encoded = encoded [ : length - 3 ] # Truncating the string encoded as UTF-8 may have left the final codepoint # only partially present. Pass 'ignore' to acknowledge and ensure this is # dropped. return encoded . decode ( 'utf-8' , 'ignore' ) + "..." return s