Welcome to WebmasterWorld Guest from

Forum Moderators: bakedjake

Message Too Old, No Replies

How to get rid of windows special character?

must be simple but...



7:00 pm on Nov 28, 2001 (gmt 0)

10+ Year Member

This is probably very simple but I know absolutely nothing about these things...

I have some data in the mysql database entered with a windows special character (I guess sloppiness of data operators).

When I export the data into text file and open it in windows (excel or word), it behaves like a new line symbol. When I look at it in a linux editor, it shows as underlined M\ symbol.

My question is: how to get rid of it so that I can open the txt file in windows?


7:25 pm on Nov 28, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Text files are organized differently on unix or Windows/DOS. On unix, the line endings are marked with a single <newline> character (NL resp. "\n"), on Windows with a <return><newline> sequence (CR/NL resp "\r\n"). A decent text editor on both sides will have no problems with that, and will display a file correctly, assuming that all lines in the file use one convention consistently.

A less decent text editor on unix will display the <return> characters as "^M" ("<control>M" is the convention for most unix terminals to enter the ASCII value of 0x0D). A less decent editor on Windows will display a file in unix convention all on one line, with something garbled where the lines were meant to break.
Btw: To add to the confusion, on the traditional Mac systems, line endings were marked with a <return> character alone, but I think that OS-X is leaning more towards the unix conventions.

Solution? Get a decent text editor!
On Windows, Wordpad does nicely, on unix (and elsewhere) I use vim myself, but that may not be suitable for the faint of heart... ;). I'm sure there are many other decent editors, just shop around. Of course, if one file mixes several conventions on seperate lines, then there's no solution. Such a file is simply broken.


10:14 am on Nov 29, 2001 (gmt 0)

10+ Year Member

Thanks bird for your help. We have decided to filter out from the data all these redundant \r\n characters to solve the problem of mixed special characters. Otherwise it would come back on us every time we want to reuse the data in windows...


6:05 pm on Nov 29, 2001 (gmt 0)

10+ Year Member

Found the solution. Might be useful for other newbies in future:

To get rid of windows new line character:

% sed -e "s/^M//" filename > newfilename

To enter ^M, type CTRL-V, then CTRL-M. That is, hold down the CTRL key then press V and M in succession.


Featured Threads

Hot Threads This Week

Hot Threads This Month