note 63222 added to function.utf8-encode

From: Date: Thu, 16 Mar 2006 12:46:52 +0000
Subject: note 63222 added to function.utf8-encode
Groups: php.notes 
Request: Send a blank email to php-notes+get-105923@lists.php.net to get a copy of this message
If you are looking for a function to replace special characters with the hex-utf-8 value (e.g. für Webservice-Security/WSS4J compliancy) you might use this: $textstart = "Größe"; $utf8 =''; $max = strlen($txt); for ($i = 0; $i < $max; $i++) { if ($txt{i} == "&"){ $neu = "&x26;"; } elseif ((ord($txt{$i}) < 32) or (ord($txt{$i}) > 127)){ $neu = urlencode(utf8_encode($txt{$i})); $neu = preg_replace('#\%(..)\%(..)\%(..)#','&#x\1;&#x\2;&#x\3;',$neu); $neu = preg_replace('#\%(..)\%(..)#','&#x\1;&#x\2;',$neu); $neu = preg_replace('#\%(..)#','&#x\1;',$neu); } else { $neu = $txt{$i}; } $utf8 .= $neu; } // for $i $textnew = $utf8; In this example $textnew will be "Gr&#xC3;&#xB6;&#xC3;&#x9F;e" ---- Server IP: 217.160.72.57 Probable Submitter: 217.6.189.194 ---- X-Spam-Status: Yes, hits=7.4 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HEAD_ILLEGAL_CHARS autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.utf8-encode.php Edit -- http://master.php.net/note/edit/63222 Del: integrated -- http://master.php.net/note/delete/63222/integrated Del: useless -- http://master.php.net/note/delete/63222/useless Del: bad code -- http://master.php.net/note/delete/63222/bad+code Del: spam -- http://master.php.net/note/delete/63222/spam Del: non-english -- http://master.php.net/note/delete/63222/non-english Del: in docs -- http://master.php.net/note/delete/63222/in+docs Del: other reasons-- http://master.php.net/note/delete/63222 Reject -- http://master.php.net/note/reject/63222 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#105923) next »