Am 22.06.2011 15:30, schrieb Gustavo Lopes: > Em Wed, 22 Jun 2011 13:21:10 +0100, Reindl Harald <h.rei...@thelounge.net> > escreveu: > >> Am 22.06.2011 14:14, schrieb Gustavo Lopes: >>> It's actually 3 lines: >>> >>> function str_is_utf8($str) { >>> return $str == "" || htmlspecialchars($str, 0, "UTF-8"); >>> } >> >> >> WTF should this do? >> this won't return boolean >> > > The reason it works is that > 1) || coerces the operands into booleans (if they get to be evaluated) > 2) htmlspecialchars returns "" on bad input sequence > 3) (bool) "" === false > > But even if you didn't know these things, you should have bothered to at > least test it > before sending this response
and why this will not return true if $str is ISO-8859-1?
signature.asc
Description: OpenPGP digital signature