Re: regex - filtering out chinese utf8 characters

From: Date: Thu, 30 Jul 2009 21:37:05 +0000
Subject: Re: regex - filtering out chinese utf8 characters
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-296076@lists.php.net to get a copy of this message
Merlin Morgenstern wrote: > Hi there, > > I am trying to filter out content that is not ascii. Can I do this with > regex? For example: > > $regex = '[AZ][09]'; > if (preg_match($regex, $text)) { > return TRUE; > } > else { > return FALSE; > } > > The reason I need to do this is that I am doing a mysql query with the > text and I need to make sure it is not UTF8. Otherwise I do get > following error: > > Error: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) > and (utf8_general_ci,COERCIBLE) for operation '=' > > I am new to regex and would be happy for a jump start to get this fixed. > > Best regards, Merlin > You might want to read up on iconv. I think it will do what you are wanting to do. http://us2.php.net/manual/en/book.iconv.php specifically... http://us2.php.net/manual/en/function.iconv.php

« previous php.general (#296076) next »