473,396 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to get rid of control M character

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
4 16950
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Nathan Griffiths | last post by:
I have been testing our SQL Mail setup in SQL Server 2000 (sp3a) and have found that when I attach results as a file, every other character is a control character which causes each real character...
6
by: Marco Montel | last post by:
I have two applications that should comunicate through an xml file. This xml will contain a CDATA section with a digital signature. The problem is that the digital signature is composed of...
1
by: coolcoon | last post by:
Hello In a C++ program, I would like to change the string "ty^Hypescript ^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^ ^H^H ^H^H ^H^H ^H^G^G^G^G^Gty^Hypescript ^H ^H^H ^H^H ^H^H ^H^M" into the...
2
by: zdrakec | last post by:
Hello all: I hope someone can explicate this for me: I have a csv file whose last line consists of two characters are the hex char 1A (decimal 26, or ^Z) followed by an equal sign ("="), thus:...
15
by: pkaeowic | last post by:
I am having a problem with the "escape" character \e. This code is in my Windows form KeyPress event. The compiler gives me "unrecognized escape sequence" even though this is documented in MSDN....
11
by: Ron L | last post by:
I have a barcode scanner which uses a "keyboard wedge" program so that the data it scans comes through as if it was typed on a keyboard. I am trying to have the data in the barcode be displayed in...
5
by: Sebastian Araya | last post by:
Hello, I'm trying to write a rotational symbol in a CLI process, to report activity to the user console, using printf( "%s\b", symbol ); but I see the control character (\b) is been printed out...
4
by: R.A.M. | last post by:
Hello, I have little experience in PHP so I would like to ask a question. I use PHP5 in Windows XP Professional, Apache 2.0.59. I have created a website with index.php file. This file contains:...
7
by: wannymahoots | last post by:
optparse seems to be escaping control characters that I pass as arguments on the command line. Is this a bug? Am I missing something? Can this be prevented, or worked around? This behaviour...
10
by: Paul W | last post by:
Hi all, I have an application that reads data in from a text file and stores it in a database. My problem is that there are some characters in the file that aren't being handled properly. For...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.