Returns a string encoded using UTF-8.

  This function comes from `Tornado`_.

  :param value:
    A unicode or string to be encoded.
  :returns:
    The encoded string.

def to_utf8(value):
  """Returns a string encoded using UTF-8.

  This function comes from `Tornado`_.

  :param value:
    A unicode or string to be encoded.
  :returns:
    The encoded string.
  """
  if isinstance(value, unicode):
    return value.encode('utf-8')

  assert isinstance(value, str)
  return value