php-general Digest 4 Jun 2010 10:16:10 -0000 Issue 6781
Topics (messages 305789 through 305796):
convert files utf8
305789 by: Tanel Tammik
305791 by: Tanel Tammik
305792 by: Ashley Sheridan
305794 by: Tanel Tammik
305795 by: Richard Quadling
Re: CakePHP, alternatives?
305790 by: Shreyas
Re: Parse info from 1,000 files to file
305793 by: Jim Lucas
Script to add domain users to local groups on remote machines
305796 by: Mayer, Jonathan
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
OP win xp pro
""Tanel Tammik"" <[email protected]> wrote in message
news:[email protected]...
> 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
>
--- End Message ---
--- Begin Message ---
On Fri, 2010-06-04 at 00:38 +0300, Tanel Tammik wrote:
> OP win xp pro
>
>
> ""Tanel Tammik"" <[email protected]> wrote in message
> news:[email protected]...
> > 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
> >
>
>
>
Could you not just open them all and save them again as utf8 files? Even
notepad can save to utf8.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
"Ashley Sheridan" <[email protected]> wrote in message
news:1275607105.2217.31.ca...@localhost...
> On Fri, 2010-06-04 at 00:38 +0300, Tanel Tammik wrote:
>
>> OP win xp pro
>>
>>
>> ""Tanel Tammik"" <[email protected]> wrote in message
>> news:[email protected]...
>> > 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
>> >
>>
>>
>>
>
>
> Could you not just open them all and save them again as utf8 files? Even
> notepad can save to utf8.
>
>
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
Isn't there a xp program for that to convert all files at once?
Tanel
--- End Message ---
--- Begin Message ---
On 3 June 2010 22:35, Tanel Tammik <[email protected]> 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
--- End Message ---
--- Begin Message ---
Larry,
That's a very nice way to learn stuff. That's what I am doing but probably
in a very crude way.
I am just reading a PHP book and doing those examples. Would you recommend
any other innovative way of learning and mastering this language?
Regards,
Shreyas
On Thu, Jun 3, 2010 at 11:25 PM, [email protected] <
[email protected]> wrote:
> First spend time working with straight up PHP, writing your own stuff,
> throwing it away, and writing it again. What you'll learn that way is
> immeasurable.
>
> Then pick a framework (Cake, Drupal, Symfony, Zend, PEAR, whatever) and
> learn it, maybe two. Try working with it and extending it.
>
> Then do the bulk of your serious work with that framework, having had
> enough experience to understand what it's doing and why.
>
> The timeframe for that process will vary widely from a few months to a few
> years depending on how quickly you pick stuff up and how much time you have,
> but that's going to get you the best education and productivity.
>
> --Larry Garfield
>
>
> On 6/3/10 12:51 PM, Shreyas wrote:
>
>> Folks,
>>
>> Just quite could not stop taking your inputs before I start my learning
>> curve to shape up.
>>
>> Should I use one of these frameworks or just *K*eep *I*t *S*imple and
>> *S*tupid
>>
>> and learn it the traditional way? Thoughts?
>>
>>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Regards,
Shreyas
--- End Message ---
--- Begin Message ---
Sam Smith wrote:
> Can someone briefly point me to the functions I'll need to parse some
> information from thousands of files in a single directory and then
> prepare the extracted info into a single file for SQL import?
>
> Like file() or readfile() and some regex and writefile??
>
> Thanks
>
since you did not say what type of data was in the files, I will assume it is
CSV data in my example.
<?php
$files = '/path/to/files/';
if ( is_dir($files) )
{
if ( ($file_list = glob("{$files}*") ) !== false )
{
if ( !empty($file_list) )
{
foreach ( $file_list AS $file )
{
if ( ($fh = fopen($file, 'r') ) !== false )
{
while ( !feof($fh) ) {
$line = fgetcsv($fh);
# at this point, you should have your data in an array
# process said data one line at a time.
}
}
}
}
}
}
Another option that you could add to this is instead of cleaning your data and
inserting it into your DB, you could create a tmp file that all the data in
shoved into. Then, once you are done processing all the original files, you
could then insert the data into your database with its LOAD FILE option.
--
Jim Lucas
A: Maybe because some people are too annoyed by top-posting.
Q: Why do I not get an answer to my question(s)?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
--- End Message ---
--- Begin Message ---
Hello,
Has anyone got any ideas how I might add a user to a local group on a
remote networked Windows machine via a PHP script? The idea is to make
an automated tool where users can request access to a shared folder via
our intranet, and after suitable approval the system add them to a group
which has read privileges for the folder in question.
If I run apache using an account with suitable privileges, I've been
able to do it with COM, but for security reasons I'd like to be able to
authenticate through the script instead, and leave apache running on the
standard local system account.
Perhaps COM is the wrong way to go about the problem - perhaps exec? Any
ideas gladly appreciated!
Thanks,
Jon.
--- End Message ---