def valid_string(val):
 for char in val:
  try:
   char = ord(char)
  except TypeError:
   raise NotValid('string')
  if ((char == 9) or (char == 10) or (char == 13)):
   continue
  elif (32 <= char <= 55295):
   continue
  elif (57344 <= char <= 65533):
   continue
  elif (65536 <= char <= 1114111):
   continue
  else:
   raise NotValid('string')
 return True

def valid_string ( val ) : for char in val : try : char = ord ( char ) except TypeError : raise NotValid ( 'string' ) if ( ( char == 9 ) or ( char == 10 ) or ( char == 13 ) ) : continue elif ( 32 <= char <= 55295 ) : continue elif ( 57344 <= char <= 65533 ) : continue elif ( 65536 <= char <= 1114111 ) : continue else : raise NotValid ( 'string' ) return True
expects unicode char ::= #x9 | #xa | #xd | [#x20-#xd7ff] | [#xe000-#xfffd] | [#x10000-#x10ffff] .