'Check string coding, length, and line break character'

def check_string(self, value):

    if (value is None):
        return
    if (not isinstance(value, unicode)):
        value = unicode(value, self.encoding)
    value = unicode(value)
    value = value[:32767]
    if next(ILLEGAL_CHARACTERS_RE.finditer(value), None):
        raise IllegalCharacterError
    return value
