frizzle wrote:
tim wrote: frizzle wrote: Hi Group,
I have a validation function, to make sure
all chars in a string will create output (including space).
I use ctype_print() but i get an error with chars like e.g.
à «
It returns false instead of true.
is there any alternative, or can i solve this?
Frizzle.
Hi Frizzle
I'm not sure but I changing the default_charset with ini_set() or maybe
setlocale() should help.
Tim
Thanks, but i'm not experienced (yet) with charsets, ini_set, etc. So i
was hoping
some kind of preg_match or so to replace ctype_print() with ...
Frizzle,
Ok, if preg_match( '/[^\s\w]/', "teststring" ) returns true then
non-printable characters were found
But it may not work because the manual suggest the \w in preg_match is
limited by the charset and locale settings as well.
If it doesn't work then try ini_set('default_charset',"UTF-8") or put
default_charset=UTF-8 in your php.ini
setlocale() won't really help, it might make a few more characters pass
the ctype_print test but not all of them.
Another option is $okChars = preg_replace_all( /[^\s\w]/, '',
"teststring" ) to remove any chars which aren't whitespace or a word
character from the test string and $okString is left with what preg
recognised as ok.
Tim