Jump to content

^m In Config Files On Mark Iii


Recommended Posts

The Config menu on the Mark III makes it easy to update a variety of config files. Unfortunately the way PHP is writing to those files it is adding additional linebreaks which are showing up as ^M when seen in vi (but not the config page or cat).

Here's a little more on the problem: http://hints.macworld.com/article.php?story=20001206164827794

Adding $newdata = preg_replace('/\r/', "\n", $newdata); after the { on line 18 of config.php would solve the issue, except that the version of PHP on the Mark III doesn't support PCRE or Perl Compatible Regular Expressions.

So while I'm researching a way to solve this for the upcoming 1.0.2 update, I'm wondering if any PHP gurus out there know of the tops of their heads how to do the same without using the preg_replace() function. Perhaps ereg_replace()?

Thanks, appreciate any input. Cheers.

Link to comment
Share on other sites

Not sure if this helps but found this on php.net

http://www.php.net/manual/en/function.strtr.php#60195

// if you are upset with windows' ^M characters at the end of the line,
// these two lines are for you:
$trans = array("\x0D" => "");
$text = strtr($orig_text,$trans);

// note that ctrl+M (in vim known as ^M) is hexadecimally 0x0D

OR

https://bugs.php.net/bug.php?id=3169&edit=3

$string = ereg_replace(13,  "", $string);  /* get rid of Ctrl-M */ 

Edited by brianzimm
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...