note 97749 deleted from function.sscanf by danbrown

From: Date: Thu, 06 May 2010 14:32:45 +0000
Subject: note 97749 deleted from function.sscanf by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169008@lists.php.net to get a copy of this message
Note Submitter: Calle Kabo ---- Igors solution includes all US-ASCII-characters, but if the text contains extended ASCII-characters it fails. Here's how I did: <?php $str = "pos1normalpos2åäöü»ß"; $format = "%10[\x20-\x7E\x80-\xFF]%10[\x20-\x7E\x80-\xFF]"; var_dump(sscanf($str, $format)); ?> array(2) { [0]=> string(10) "pos1normal" [1]=> string(10) "pos2åäöü»ß" } The skipped \x7F is the delete char. If that is included (x20-\xFF) it doesn't work. Note however that sscanf can not handle mutlibyte chars like UTF-8. If the string above would have been UTF-8 encoded, the second string would only have been "pos2åäö"

« previous php.notes (#169008) next »