...

View Full Version : Non-Standard newline character



Blaher
12-20-2010, 11:05 PM
I'm working on a website where the owner will be uploading a dump file, generated from a MS Server 2003 project someone else did. I'm created a quick script to upload the file off of his computer and on to the server, then run a MySQL query to load it in to a table. Basically like this:

$SQL = "LOAD DATA LOCAL INFILE '" . $file_member . "' INTO TABLE tmpMemberImport FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\\r' STARTING BY '\\n'";

The problem is, the .txt file that is dumped by whatever software that's running on their ISS server is using some strange newline character. If you open it up with notepad in Windows XP, it's just a unknown character block. Is there anyway in PHP I can replace these characters to fit the "\r\n" standard? I know you can just use str_replace, but I don't even know what this character is, how to find out what it is, or if anyone has had a similar problem?

jmace
12-20-2010, 11:44 PM
Have you tried replacing "/(\r|\n)/" with "\r\n" ?

I suspect it's using either \r or \n and not both (which is why windows can't figure out what the character is). A quick preg_replace() should fix it, I would think.

Also, IDE's like eclipse can usually read (and change) any kind of newline delimiter. So it might be helpful to open it in one and then save it with the proper \r\n.

Might be stuff you already know, but hopefully it helps.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum