How to Convert \r\n to \n

S

Sachin

I download an opensource java program named chabria text normalizer
which normalizes a string according to a set of rules defined in a
seperate file. This file is read by the program to apply rules. Source
for parse this rules is auto generated by another opensource program
named JavaCC. I run this program on Wndows
When i change something this file program throws an exception " replace
\r\n with \n ....".
I use notepad on windows to edit the rule file.
Notepad use \r\n to present newline, and i think this may be thew cause
for this error. And this text normalizer program is generated on a Unix
platform.
I want to run this on Windows and please tell me how do I avoid this.
This is realy a headache for me.
 
D

Dave Glasser

in comp.lang.java.programmer:

When i change something this file program throws an exception " replace
\r\n with \n ....".

Gee, that's a very odd error message. There's not much information
there. I wonder why the progammer chose to end his error message with
"...."?


--
Check out QueryForm, a free, open source, Java/Swing-based
front end for relational databases.

http://qform.sourceforge.net

If you're a musician, check out RPitch Relative Pitch
Ear Training Software.

http://rpitch.sourceforge.net
 
S

Steve Horsley

Sachin said:
I download an opensource java program named chabria text normalizer
which normalizes a string according to a set of rules defined in a
seperate file. This file is read by the program to apply rules. Source
for parse this rules is auto generated by another opensource program
named JavaCC. I run this program on Wndows
When i change something this file program throws an exception " replace
\r\n with \n ....".
I use notepad on windows to edit the rule file.
Notepad use \r\n to present newline, and i think this may be thew cause
for this error. And this text normalizer program is generated on a Unix
platform.
I want to run this on Windows and please tell me how do I avoid this.
This is realy a headache for me.

You could try and look for a proggy called dos2unix that converts
text files this way. It usually comes with its friend, unix2dos.

Steve
 
S

Steve W. Jackson

Steve Horsley said:
You could try and look for a proggy called dos2unix that converts
text files this way. It usually comes with its friend, unix2dos.

Steve

Better still, lose Notepad. Wordpad understands Unix-style line endings.

= Steve =
 
O

Oliver Wong

Steve W. Jackson said:
Better still, lose Notepad. Wordpad understands Unix-style line endings.

If this is true, I was unable to find the feature in Wordpad that allows
one open an ASCII file with Microsoft-style line endings, and then re-save
it as an ASCII file with Unix-style line endings.

The OP may be interested in more feature-filled text editors. I use
jEdit, and to perform the conversion, you just need to open the document,
and choose the menu "Utitilies->Buffer Options". A window will pop up, and
one of the drop down menus reads "Line seperator". Set this to "Unix (\n)"
and save the document.

http://www.jedit.org/

- Oliver
 
R

Raymond DeCampo

Oliver said:
If this is true, I was unable to find the feature in Wordpad that allows
one open an ASCII file with Microsoft-style line endings, and then re-save
it as an ASCII file with Unix-style line endings.

I think by "Wordpad understands Unix-style line endings", Steve meant
that a file with \n line separators can be opened in a sane manner by
Wordpad. I wouldn't read into this the ability to change back and forth
between them.
The OP may be interested in more feature-filled text editors. I use
jEdit, and to perform the conversion, you just need to open the document,
and choose the menu "Utitilies->Buffer Options". A window will pop up, and
one of the drop down menus reads "Line seperator". Set this to "Unix (\n)"
and save the document.

http://www.jedit.org/

I'll second that recommendation. Unfortunately however you may
sometimes be working on Windows machines where you do not have the
ability to install applications or maybe you just want to quickly view a
log file. In that case, it is good to understand what both Notepad and
Wordpad can do for you. (Believe it or not, there are cases where
Notepad is superior.) This is analogous to the Unix admin's need to
know vi, even if they prefer something else.

HTH,
Ray
 
H

Hendrik Maryns

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Steve W. Jackson uitte de volgende tekst op 01/20/2006 09:57 PM:
Better still, lose Notepad. Wordpad understands Unix-style line endings.

Better still, get notepad2: http://www.flos-freeware.ch/notepad2.html,
that doesn?t give you the inconvenience of wordpad trying to save
everything as rtf which is opened by Word the next time.

H.
- --
Hendrik Maryns

==================
www.lieverleven.be
http://aouw.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFD1AHaimZ/5+ZTkokRAi9XAJ4pzeKKuwUkWBRNQu2vgSKniDX0cACfXI42
dIuVZ+19sLttUKX66pX1Oeo=
=NGqT
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top