Mailinglisten-Archive |
--HlL+5n6rz5pIUxbD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline siehe anhang... On Sat, Jul 22, 2000 at 11:28:40AM +0200, Andreas Korinek wrote: > Hallo Liste, > > wei? jemand von Euch ob es eine Umkehrfunktion vom htmlentities gibt, die z.B. > "ü" wieder in "?" umwandelt? > > -- > Mit freundlichen Gr??en > > Andreas Korinek > > info_(at)_bonsai-welt.de > > -- > ** Durchgehend ge?ffnet: http://www.php-center.de ** > Die PHP-Liste: mailto:php_(at)_php-center.de > http://infosoc.uni-koeln.de/mailman/listinfo/php -- Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!" Digital Collections Phone +49 40 235350 Fax +49 40 23535180 Hammerbrookstr. 93 20097 Hamburg / Germany --HlL+5n6rz5pIUxbD Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 8bit Date: Fri, 2 Jun 2000 12:08:50 +0200 From: "Thies C . Arntzen" <thies_(at)_digicol.de> To: =?iso-8859-1?Q?Martin_Storsj=F6?= <martin.storsjo_(at)_pp.qnet.fi> Cc: php-general_(at)_lists.php.net Subject: Re: [PHP-GENERAL] Reverse htmlentities Message-ID: <20000602120850.E1259_(at)_godzilla.digicol.de> References: <3936C424.46E66A08_(at)_pp.qnet.fi> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="9jxsPFA5p3P2qPhR" Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.3.2i In-Reply-To: <3936C424.46E66A08_(at)_pp.qnet.fi>; from martin.storsjo_(at)_pp.qnet.fi on Thu, Jun 01, 2000 at 11:14:28PM +0300 Return-Path: <thies_(at)_digicol.de> --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit On Thu, Jun 01, 2000 at 11:14:28PM +0300, Martin Storsjö wrote: > Is there any way of doing a "reverse htmlentities()", e.g. translating > "hello world" into "hello world", but also all other possible > codes? I could of course use strtr in some way, but that's not what I'm > looking for. > > // Martin see my attached message. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe_(at)_lists.php.net > For additional commands, e-mail: php-general-help_(at)_lists.php.net > To contact the list administrators, e-mail: php-list-admin_(at)_lists.php.net -- Thies C. Arntzen "One Big-Mac, Small Fries and a Coke!" Digital Collections Phone +49 40 235350 Fax +49 40 23535180 Hammerbrookstr. 93 20097 Hamburg / Germany --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=1 Subject: strtr(),get_html_translation_table(),array_flip() - or "how to reverse htmlspecialchars()/htmlenities()" Message-ID: <Pine.LNX.4.20.9911211426570.27442-100000_(at)_godzilla.digicol.old> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT hi, just committed some useful stuff to PHP 4 cvs: (maybe some of the doc-guys feels strong enmoght to write the docs for it?) strtr() can now be called with only 2 arguments. if called with just 2 args it behaves in a new way: arg2 then has to be an array that contains string->string pairs that will be replaces in the source-string. strtr will always look for the longest possible match 1st and will *NOT* try to replace in stuff that it has already worked on! $trans = array("hallo" => "hi", "hi" => "hallo"); echo strtr("hi all, i said hallo",$trans)."\n"; will show: hallo all, i said hi get_html_translation_table(int which) will return the translation tables that php used internally for htmlspecialchars() and htmlentities(). there are two new defines (HTML_ENTITIES, HTML_SPECIALCHARS) that allow you to specify the table you want (this leaves us room for implemeting other that 8859-1 charsets;-) so you can now write your own htmlentities() that works *exactly* like the builtin one: $trans = get_html_translation_table(HTML_ENTITIES); $str = "Hallo & <Pallo> & k<FC><DF>chen"; $encoded = strtr($str,$trans); $encoded will now be: Hallo & <Pallo> & küßchen the cool "new" this is that using array_flip() you can change the direction of the translation! $trans = array_flip($trans); $original = strtr($str,$trans); and $original will be Hallo & <Pallo> & k<FC><DF>chen again! have fun, tc --9jxsPFA5p3P2qPhR-- --HlL+5n6rz5pIUxbD--
php::bar PHP Wiki - Listenarchive