By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

How to get rid of control M character

P: n/a
Hi,

I'm using PHP code to develop a www interface to let users edit text
files stored on a Solaris UX server. Users are using Windows based
WWW browser access this web site. Once they have selected the file
they want to edit, it's presented in a text window (form) so thay can
modify the file.

The submit button passes the contents of the field to a variable and
it is saved to disc.

From the WWW interface everything seems OK, but when I look to the
file, each line has a "^M" (control-M) at the end.

This makes the files bigger and it can cause problem in a near future
because these files have to be processed by shell scripts to populate
a mySQL DB.

Someone has seen that before and what was the solution.

Thanks,
Alain
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On 2003-12-05, Alain Forget <Al******@hotmail.com> wrote:
Hi,

I'm using PHP code to develop a www interface to let users edit text
files stored on a Solaris UX server. Users are using Windows based
WWW browser access this web site. Once they have selected the file
they want to edit, it's presented in a text window (form) so thay can
modify the file.

The submit button passes the contents of the field to a variable and
it is saved to disc.

From the WWW interface everything seems OK, but when I look to the
file, each line has a "^M" (control-M) at the end.


Just run dos2unix on the files. (this will remove the <cr>)

--
verum ipsum factum
Jul 17 '05 #2

P: n/a
Tim Van Wassenhove wrote:
On 2003-12-05, Alain Forget <Al******@hotmail.com> wrote:
From the WWW interface everything seems OK, but when I look to the
file, each line has a "^M" (control-M) at the end.


Just run dos2unix on the files. (this will remove the <cr>)


If you don't have access to that, before writing the file use something
like:

$contents=preg_replace('/(\r\n|\r|\n)/s',"\n",$contents);

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

Jul 17 '05 #3

P: n/a
Use strtr(). It's designed for situations like yours.

$text = strtr($text, array("\r" => ""));

Uzytkownik "Alain Forget" <Al******@hotmail.com> napisal w wiadomosci
news:dc**************************@posting.google.c om...
Hi,

I'm using PHP code to develop a www interface to let users edit text
files stored on a Solaris UX server. Users are using Windows based
WWW browser access this web site. Once they have selected the file
they want to edit, it's presented in a text window (form) so thay can
modify the file.

The submit button passes the contents of the field to a variable and
it is saved to disc.

From the WWW interface everything seems OK, but when I look to the
file, each line has a "^M" (control-M) at the end.

This makes the files bigger and it can cause problem in a near future
because these files have to be processed by shell scripts to populate
a mySQL DB.

Someone has seen that before and what was the solution.

Thanks,
Alain

Jul 17 '05 #4

P: n/a
Justin Koivisto <sp**@koivi.com> wrote in message news:<ez*****************@news7.onvoy.net>...
Tim Van Wassenhove wrote:
On 2003-12-05, Alain Forget <Al******@hotmail.com> wrote:
From the WWW interface everything seems OK, but when I look to the
file, each line has a "^M" (control-M) at the end.


Just run dos2unix on the files. (this will remove the <cr>)


If you don't have access to that, before writing the file use something
like:

$contents=preg_replace('/(\r\n|\r|\n)/s',"\n",$contents);


Justin,

The preg_replace command acts like magic on my files.

THANK YOU, THANK YOU ... 1000 times....!!! ;-)

Alain
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.