Re: what character is a physical newline
On Mon, Jun 29, 2009 at 06:56:48AM +0100, Matthew Seaman wrote: > Aryeh M. Friedman wrote: > >Glen Barber wrote: > >>On Sun, Jun 28, 2009 at 10:21 PM, Aryeh M. > >>Friedman wrote: > >> > >>>I am writting a parser (tokenizes all characters among other things) and > >>>need to know what control char is equivelent to a newline (I do not need > >>>windows cross compatibility) > >>> > >> > >>What do you mean exactly? What language(s)? If I understand your > >>question correctly, the C / C++ / Java / PHP (and I think Perl) > >>'newline' character is '\n' > >> > >> > >I meant what ascii character does \n actual correspond to (I assume > >but just making sure) > > On Unix, the end of line character is NL (012 octal, 10 decimal, 0x0a hex) > -- > see ascii(7). Some people know it as Ctrl-J Gee, wouldn't you know it, in FreeBSD, there is even a man page for it. jerry > > Cheers, > > Matthew > > -- > Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard > Flat 3 > PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate > Kent, CT11 9PW > ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: what character is a physical newline
On Sun, Jun 28, 2009 at 10:38:20PM -0400, Vince Sabio wrote: > ** At 22:30 -0400 on 06/28/2009, Glen Barber wrote: > >On Sun, Jun 28, 2009 at 10:27 PM, Aryeh M. Friedman wrote: > > >> > >>> What do you mean exactly? What language(s)? If I understand your > >>> question correctly, the C / C++ / Java / PHP (and I think Perl) > > >> 'newline' character is '\n' > > > > >> I meant what ascii character does \n actual correspond to (I assume > >> but > > > just making sure) > > No, CR is a carriage return, which is a \r in C, and is an ASCII 13 (hex > 0D). > > "Newline" is a line feed (LF), which is a \n in C, and is an ASCII 10 (hex > 0A) > > >Oh. IIRC, CR is the DOS way, and LR is the POSIX way. > > Not exactly; CRLF is the DOS way, CR is the Macintosh way, and LF is > Unix/Posix. A quick Google search for ASCII came up with this page: http://www.asciitable.com/ Which correctly lists Line Feed (LF) as: Decimal 10, Hex 0A, Octal 012 Carriage Return (CR) is: Decimal 13, Hex 0D, Octal 015 jerry > > HTH. > > __ > Vince Sabio vi...@vjs.org > ___ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org" ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: what character is a physical newline
Hi, Am Sonntag, 28. Jun 2009, 22:27:49 -0400 schrieb Aryeh M. Friedman: > Glen Barber wrote: >> On Sun, Jun 28, 2009 at 10:21 PM, Aryeh M. >> Friedman wrote: >> >>> I am writting a parser (tokenizes all characters among other things) and >>> need to know what control char is equivelent to a newline (I do not need >>> windows cross compatibility) >> >> What do you mean exactly? What language(s)? If I understand your >> question correctly, the C / C++ / Java / PHP (and I think Perl) >> 'newline' character is '\n' >> > I meant what ascii character does \n actual correspond to (I assume > but just making sure) $ perl -e 'print ord("\n"), "\n"' 10 $ python -c 'print ord("\n")' 10 $ ruby -e 'puts "\n"[0]' 10 $ cat nl.c #include "stdio.h" int main(int argc, char **argv) { printf( "%d\n", '\n'); return 0; } $ cc -o nl nl.c $ ./nl 10 $ echo | od -d 00010 001 Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: what character is a physical newline
Aryeh M. Friedman wrote: Glen Barber wrote: On Sun, Jun 28, 2009 at 10:21 PM, Aryeh M. Friedman wrote: I am writting a parser (tokenizes all characters among other things) and need to know what control char is equivelent to a newline (I do not need windows cross compatibility) What do you mean exactly? What language(s)? If I understand your question correctly, the C / C++ / Java / PHP (and I think Perl) 'newline' character is '\n' I meant what ascii character does \n actual correspond to (I assume but just making sure) On Unix, the end of line character is NL (012 octal, 10 decimal, 0x0a hex) -- see ascii(7). Some people know it as Ctrl-J Cheers, Matthew -- Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard Flat 3 PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate Kent, CT11 9PW signature.asc Description: OpenPGP digital signature
Re: what character is a physical newline
Just incase you guys are curious the reason for doing the parser from scratch is it is designed to lex/parse families of languages not just a single lang for example (there is very large overlap between c/c++/java/c#/etc. as there is in the tag langs like XML/HTML)... also generators produce unreadable code (and impossible to hand modify if you're not quite happy with the generated code) thus I refer to the design as a heiractical recursive decent parser (i.e. it lexs/parses the commonalties of a family [or set of families {all ascii vs, unicode langs for example are a set of families} before it attempts to handle the actual lang [or family in the case of set of families]). ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: what character is a physical newline
On Sun, Jun 28, 2009 at 10:38 PM, Vince Sabio wrote: > ** At 22:30 -0400 on 06/28/2009, Glen Barber wrote: >> >> On Sun, Jun 28, 2009 at 10:27 PM, Aryeh M. Friedman wrote: >> >> What do you mean exactly? What language(s)? If I understand your question correctly, the C / C++ / Java / PHP (and I think Perl) >> >> >> 'newline' character is '\n' >> > >>> >>> I meant what ascii character does \n actual correspond to (I assume >>> but >> >> > just making sure) > > No, CR is a carriage return, which is a \r in C, and is an ASCII 13 (hex > 0D). > > "Newline" is a line feed (LF), which is a \n in C, and is an ASCII 10 (hex > 0A) > >> Oh. IIRC, CR is the DOS way, and LR is the POSIX way. > > Not exactly; CRLF is the DOS way, CR is the Macintosh way, and LF is > Unix/Posix. > > HTH. > Thanks for correcting me. Goes to show that bad advice is worse than no advice. :) -- Glen Barber ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: what character is a physical newline
On Sun, Jun 28, 2009 at 10:39 PM, Aryeh M. Friedman wrote: >> Oh. IIRC, CR is the DOS way, and LR is the POSIX way. >> >> > > Don't you mean LF not LR? > I did. I realized it after Vince replied. -- Glen Barber ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: what character is a physical newline
Glen Barber wrote: On Sun, Jun 28, 2009 at 10:27 PM, Aryeh M. Friedman wrote: What do you mean exactly? What language(s)? If I understand your question correctly, the C / C++ / Java / PHP (and I think Perl) 'newline' character is '\n' I meant what ascii character does \n actual correspond to (I assume but just making sure) Oh. IIRC, CR is the DOS way, and LR is the POSIX way. Don't you mean LF not LR? ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: what character is a physical newline
** At 22:30 -0400 on 06/28/2009, Glen Barber wrote: On Sun, Jun 28, 2009 at 10:27 PM, Aryeh M. Friedman wrote: >> What do you mean exactly? What language(s)? If I understand your question correctly, the C / C++ / Java / PHP (and I think Perl) >> 'newline' character is '\n' > I meant what ascii character does \n actual correspond to (I assume but > just making sure) No, CR is a carriage return, which is a \r in C, and is an ASCII 13 (hex 0D). "Newline" is a line feed (LF), which is a \n in C, and is an ASCII 10 (hex 0A) Oh. IIRC, CR is the DOS way, and LR is the POSIX way. Not exactly; CRLF is the DOS way, CR is the Macintosh way, and LF is Unix/Posix. HTH. __ Vince Sabio vi...@vjs.org ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: what character is a physical newline
On Sun, Jun 28, 2009 at 10:27 PM, Aryeh M. Friedman wrote: >> >> What do you mean exactly? What language(s)? If I understand your >> question correctly, the C / C++ / Java / PHP (and I think Perl) >> 'newline' character is '\n' >> >> > > I meant what ascii character does \n actual correspond to (I assume but > just making sure) > Oh. IIRC, CR is the DOS way, and LR is the POSIX way. -- Glen Barber ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: what character is a physical newline
Glen Barber wrote: On Sun, Jun 28, 2009 at 10:21 PM, Aryeh M. Friedman wrote: I am writting a parser (tokenizes all characters among other things) and need to know what control char is equivelent to a newline (I do not need windows cross compatibility) What do you mean exactly? What language(s)? If I understand your question correctly, the C / C++ / Java / PHP (and I think Perl) 'newline' character is '\n' I meant what ascii character does \n actual correspond to (I assume but just making sure) ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: what character is a physical newline
On Sun, Jun 28, 2009 at 10:21 PM, Aryeh M. Friedman wrote: > I am writting a parser (tokenizes all characters among other things) and > need to know what control char is equivelent to a newline (I do not need > windows cross compatibility) What do you mean exactly? What language(s)? If I understand your question correctly, the C / C++ / Java / PHP (and I think Perl) 'newline' character is '\n' -- Glen Barber ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
Re: what character is a physical newline
Aryeh M. Friedman wrote: I am writting a parser (tokenizes all characters among other things) and need to know what control char is equivelent to a newline (I do not need windows cross compatibility) Forgot to mention before someone recommends lex/yacc and/or some other parser generator (I am working in Java) there are internal design reasons to my over all project why I am writting a lexer/parser from scratch ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
what character is a physical newline
I am writting a parser (tokenizes all characters among other things) and need to know what control char is equivelent to a newline (I do not need windows cross compatibility) ___ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"