note 97749 added to function.sscanf

From: Date: Thu, 06 May 2010 11:02:32 +0000
Subject: note 97749 added to function.sscanf
Groups: php.notes 
Request: Send a blank email to php-notes+get-168998@lists.php.net to get a copy of this message
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åäö" ---- Server IP: 80.67.10.226 Probable Submitter: 213.115.227.252 ---- Manual Page -- http://www.php.net/manual/en/function.sscanf.php Edit -- https://master.php.net/note/edit/97749 Del: integrated -- https://master.php.net/note/delete/97749/integrated Del: useless -- https://master.php.net/note/delete/97749/useless Del: bad code -- https://master.php.net/note/delete/97749/bad+code Del: spam -- https://master.php.net/note/delete/97749/spam Del: non-english -- https://master.php.net/note/delete/97749/non-english Del: in docs -- https://master.php.net/note/delete/97749/in+docs Del: other reasons-- https://master.php.net/note/delete/97749 Reject -- https://master.php.net/note/reject/97749 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#168998) next »