Stop the presses. This is an Ajax submission (Prototype) and my request
headers showed that I was sending UTF-8. You are able to set that that with
Prototype, but that didn't help me. After some fiddling and hacking I have
managed to work around. My validate() now tests the input $value as well as
utf8_decode($value). It's kind of ugly, maybe also wrong-headed. But I don't
think it's a ZF issue after all.

On Thu, Mar 20, 2008 at 4:35 PM, David Mintz <[EMAIL PROTECTED]> wrote:

> I have a validator that is supposed to ensure that the input string has no
> character other than case-insensitive a-z, or accented characters like
> e-acute, or space.
>
> It returns false when you pass it "josé" by submitting an HTML form to my
> controller action with a browser, but  when you test it against same string
> 'josé' in a command line script, it returns true. I have tested with Opera
> 9.26 and Firefox 2.0.0.12 on a Fedora 7 system.
>
> It might be worth noting that I have used the same regex in other web
> environments, and it has worked.
>
> When I echo back the form input to the browser I see that  josé becomes
> josÃ(c) so I am guessing we have a charset issue. Any tips as to how to fix
> it? Thanks!
>
> class Model_Validator_FirstName extends Zend_Validate_Abstract {
>
>     const INVALID_CHARACTERS = 'invalidCharacters';
>
>     protected $pattern = "/[^a-zA-Z\xC0-\xFF ]/";
>
>     protected $_messageTemplates = array(
>         'invalidCharacters' => 'Firstname contains illegal characters'
>     );
>
>     function isValid($name) {
>
>         if (preg_match($this->pattern,$name)) {
>             $this->_error(self::INVALID_CHARACTERS);
>             return false;
>         }
>         return true;
>     }
> }
>


-- 
David Mintz
http://davidmintz.org/

The subtle source is clear and bright
The tributary streams flow through the darkness

Reply via email to