Re: [PHP] Re: Problem changing file encoding
Thodoris wrote: Hi guys, I am developing a project and I wrote an interface to import contracts in it. The problem is that when the user uploads the file I don't know what is the encoding it has. So I decided that a good idea is to make the user tell me the encoding from a drop down before I parse the file. Then I could probably change the encoding with iconv and use it to validate the data and make the inserts in mysql. Although in the unix world I have available the iconv command and I can change the file to the new encoding like this: iconv -f CP737 -t UTF-8 -o newfile.csv original_file.csv I can't find a way to do this from within php. Iconv support gives me some options but only to convert strings and there is not a way AFAIK to get all the supported encodings from the system as I can do in command line with this: iconv --list Is this the best way to do this ? Can I use mbstring as an alternative ? Please make any suggestions you might think because I am stuck. made this a while back.. might help :) http://programphp.com/iconv.phps Thanks Natham this is a nice approach and it certainly helps. -- Thodoris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem changing file encoding
Thodoris wrote: Hi guys, I am developing a project and I wrote an interface to import contracts in it. The problem is that when the user uploads the file I don't know what is the encoding it has. So I decided that a good idea is to make the user tell me the encoding from a drop down before I parse the file. Then I could probably change the encoding with iconv and use it to validate the data and make the inserts in mysql. Although in the unix world I have available the iconv command and I can change the file to the new encoding like this: iconv -f CP737 -t UTF-8 -o newfile.csv original_file.csv I can't find a way to do this from within php. Iconv support gives me some options but only to convert strings and there is not a way AFAIK to get all the supported encodings from the system as I can do in command line with this: iconv --list Is this the best way to do this ? Can I use mbstring as an alternative ? Please make any suggestions you might think because I am stuck. made this a while back.. might help :) http://programphp.com/iconv.phps -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php