Re: [PHP4BETA] ISO Charsets

From: Date: Wed, 22 Mar 2000 09:08:30 +0000
Subject: Re: [PHP4BETA] ISO Charsets
References: 1 2  Groups: php.version4 
Request: Send a blank email to php-version4+get-12476@lists.php.net to get a copy of this message
Hi, Well, I generated a solution to this problem for the ISO-8859-1 charset. I am posting it here in case anyone else want to use it (NO WARRANTIES, SUPPLIED "AS IS" ;-) ): Define somewhere: // convert charsets to HTML $charsets = array("iso-8859-1" => array( array("/=\r\\\n/", "/=3D/", "/=20/", "/=B4/", "/=22/", "/=26/", "/=3C/", "/=3E/", "/=([0-9A-Fa-f][0-9A-Fa-f])/e"), array("\n", "=", " ", "'", "&#34;", "&#38;", "&#60;", "&#62;", "'&#' . hexdec('\\1') . ';'") ) ); Then the convert-charset function: function convertCharset($str, $charset) { GLOBAL $charsets; $charset = strtolower($charset); if (!isset($charsets[$charset][0]) || empty($charsets[$charset][0])) return $str; else return preg_replace($charsets[$charset][0], $charsets[$charset][1], $str); } BTW, the '/e' extension to preg_replace rocks! Ciao, Andreas Andreas Pour wrote: > Ted Parnefors wrote: > > Hi, > > quoted_printable_decode is not the ticket :-(. What I would like to do is > convert a file, say, in ISO-8859-1, which may look like this: > > <HTML><HEAD> > <META content=3Dtext/html;charset=3Diso-8859-1 = > http-equiv=3DContent-Type> > <STYLE></STYLE> > <META content=3D'"MSHTML 5.00.0910.1309"' > name=3DGENERATOR></HEAD> > <BODY bgColor=3D#ffffff> > <DIV><FONT face=3DArial size=3D2>I downloaded the autoconf-1.13 from the > = > link on the=20 > web site and after installing it I still receive the error that = > I need=20 > > to something that I uses a more neutral style (the point being that I am > combining various files into one web page and so I have to eliminate > differences in encodings). What would be very helpful is a function that > converts between arbitrary (well, at least the major) charsets. > > Ciao, > > Andreas > > > On Mon, 20 Mar 2000, Andreas Pour wrote: > > > > > > > > Hi, > > > > > > Is there a way to convert ISO charsets to another charset, such as > > > us-ascii? I need to get rid of the '=20' , etc. chars. Of course I can > > > do it w/ ereg*, but I don't have specs for all the main charsets and > > > actually it would be nice to have a built-in function to do that. > > > > > > > Take a look at "quoted_printable_decode" (under the string functions > > in the manual) . Is that what you a looking for? > > > > -- > > Ted Parnefors <ted@mtv.se>, KeyID 0x6627DEE4 > > PGP Fingerprint 1C39FA94703EB54A011CF18932018E256627DEE4 > > > > -- > > PHP 4.0 Beta Mailing List > > <http://www.php.net/version4/> > > To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net > > For additional commands, e-mail: php4beta-help@lists.php.net > > To contact the list administrators, e-mail: php4beta-admin@lists.php.net > > -- > PHP 4.0 Beta Mailing List <http://www.php.net/version4/> > To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net > For additional commands, e-mail: php4beta-help@lists.php.net > To contact the list administrators, e-mail: php4beta-admin@lists.php.net

« previous php.version4 (#12476) next »