You are here: Re: problems with ctype_print « PHP Programming Language « IT news, forums, messages
Re: problems with ctype_print

Posted by tim on 10/03/16 11:48

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация