Re: Test for a unicode string

2007-10-25 Thread goldtech
snip... > > Like: > > if unicode string: > > print 'string's line #' > > else: > > process the string > If I use "re.UNICODE" like: m = re.match(r"\w+", s, re.UNICODE) then it seems to fix my problem. Trying to read as much as I can on unicode -- http://mail.python.org/ma

Re: Test for a unicode string

2007-10-25 Thread Thorsten Kampe
* goldtech (Wed, 24 Oct 2007 12:09:24 -0700) > I have a regular expression test in a script. When a unicode character > get tested in the regex it gives an error: As Martin pointed out: you are *not* using unicode... > Question: Is there a way to test a string for unicode chars (ie. test > if a

Re: Test for a unicode string

2007-10-24 Thread Martin v. Löwis
> 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 cite

Re: Test for a unicode string

2007-10-24 Thread Scott David Daniels
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 thro

Re: Test for a unicode string

2007-10-24 Thread Martin Marcher
2007/10/24, goldtech <[EMAIL PROTECTED]>: > Question: Is there a way to test a string for unicode chars (ie. test > if a string will throw the error cited above). yes there ist :) >>> isinstance(u"a", basestring) True >>> isinstance(u"a", unicode) True >>> isinstance("a", unicode) False >>> isins

Test for a unicode string

2007-10-24 Thread goldtech
Hi, 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).