Test for a unicode string

Scott David Daniels Scott.Daniels at Acm.Org
Wed Oct 24 23:45:57 EDT 2007


goldtech wrote:
> I have a regular expression test in a script. When a unicode character
> get tested in the regex it gives an error:
> 
> UnicodeError: ASCII decoding error: ordinal not in range(128)
> 
> Question: Is there a way to test a string for unicode chars (ie. test
> if a string will throw the error cited above).

How about:

     if ord(max(thestring)) >= 128:
         print 'whatever you want'

-Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list