Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Location
    North Canton, Ohio
    Posts
    118
    Thanks
    11
    Thanked 4 Times in 4 Posts

    Non-Standard newline character

    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?

  • #2
    New Coder
    Join Date
    Oct 2010
    Posts
    29
    Thanks
    0
    Thanked 2 Times in 2 Posts
    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.
    Last edited by jmace; 12-20-2010 at 10:52 PM.

  • Users who have thanked jmace for this post:

    Blaher (12-22-2010)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •