note 79174 added to function.htmlentities
| From: | TKVLPUAIBSDB at spammotel dot com | Date: | Wed, 14 Nov 2007 12:11:34 +0000 |
| Subject: | note 79174 added to function.htmlentities | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132269@lists.php.net to get a copy of this message | ||
Yet another "help paste from MS Word" function. Characters from ISO-8859-1 charset are
left in peace, while entities are built for non-standard characters from Windows CP1252.
function win1252toIso( $string ) {
// These chars seem to be not contained
// in php's CP1252 translation table
static $extensions = array(
142 => "Ž",
158 => "ž"
);
// Go through string and decide char by char:
// "leave as is or build entity?"
$newStr = "";
for( $i=0; $i < strlen( $string ); $i++ ) {
$ord = ord( $string[$i] );
if ( in_array( $ord, array_keys( $extensions ) ) ) {
// build entity using extra translation table
$newStr .= $extensions[$ord];
}
else {
// build entity using php's translation table
// or leave as is
$newStr .= ( $ord > 127 && $ord < 160 ) ?
htmlentities( $string[$i], ENT_NOQUOTES, "CP1252" )
: $string[$i];
}
}
return $newStr;
}
----
Server IP: 69.147.83.197
Probable Submitter: 194.162.250.66 (proxied: 199.99.99.45)
----
Manual Page -- http://www.php.net/manual/en/function.htmlentities.php
Edit -- https://master.php.net/note/edit/79174
Del: integrated -- https://master.php.net/note/delete/79174/integrated
Del: useless -- https://master.php.net/note/delete/79174/useless
Del: bad code -- https://master.php.net/note/delete/79174/bad+code
Del: spam -- https://master.php.net/note/delete/79174/spam
Del: non-english -- https://master.php.net/note/delete/79174/non-english
Del: in docs -- https://master.php.net/note/delete/79174/in+docs
Del: other reasons-- https://master.php.net/note/delete/79174
Reject -- https://master.php.net/note/reject/79174
Search -- https://master.php.net/manage/user-notes.php