homepage Welcome to WebmasterWorld Guest from 107.22.37.143
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Visit PubCon.com
Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
How to get rid of windows special character?
must be simple but...
starec




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

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?

 

bird




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

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.

starec




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

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...

starec




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

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved