From: Shreyas on 4 Jun 2010 06:46 I bank on Notepad++ (open source editor) to do such a thing. It can convert an ASCI file to UTF -8. Give it a shot. On Fri, Jun 4, 2010 at 2:02 PM, Richard Quadling <rquadling(a)gmail.com>wrote: > On 3 June 2010 22:35, Tanel Tammik <keevitaja(a)gmail.com> wrote: > > Hi, > > > > does anyone know how to convert all files in a directory and in it's > > subdirectories into utf8 encoding? i am using komodo edit as text-editor. > > may it has a feature which i cannot find... > > > > Br > > Tanel > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > What encoding are they currently set to? > > iconv() [1] and mb_convert_encoding() [2] may both be up to the job. > > <?php > // UNTESTED > $FilesLocation = 'C:/Work'; > $FromEncoding = 'ISO-8859-1'; > $ToEncoding = 'UTF-8'; > > foreach(new DirectoryIterator($FilesLocation) as $File) { > file_put_contents($File->getPathname(), iconv($FromEncoding, > $ToEncoding, file_get_contents($File->getPathname()))); > // file_put_contents($File->getPathname(), > mb_convert_encoding(file_get_contents($File->getPathname()), > $ToEncoding, $FromEncoding)); > } > ?> > > If the files are XML with a xml tag like ... > > <?xml version="1.0" encoding="iso-8859-1" ?> > > then you would have to add additional code to edit that line also. > > Richard. > > [1] http://docs.php.net/manual/en/function.iconv.php > [2]http://docs.php.net/manual/en/function.mb-convert-encoding.php > -- > ----- > Richard Quadling > "Standing on the shoulders of some very clever giants!" > EE : http://www.experts-exchange.com/M_248814.html > EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 > ZOPA : http://uk.zopa.com/member/RQuadling > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Regards, Shreyas
From: tedd on 4 Jun 2010 09:18 At 12:35 AM +0300 6/4/10, Tanel Tammik wrote: >Hi, > >does anyone know how to convert all files in a directory and in it's >subdirectories into utf8 encoding? i am using komodo edit as text-editor. >may it has a feature which i cannot find... > >Br >Tanel Hi Tanel: Check out: http://www.w3.org/International/questions/qa-htaccess-charset That should cover all directories and files. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com
First
|
Prev
|
Pages: 1 2 Prev: CakePHP, alternatives? Next: Script to add domain users to local groups on remote machines |