473,466 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 16953
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.