<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: Platform dependent use of &#34;\n&#34; vs &#34;\r\n&#34;</title>
		<link>http://forums.leaflabs.com/topic.php?id=172</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:19:44 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=172" rel="self" type="application/rss+xml" />

		<item>
			<title>gbulmer on "Platform dependent use of &#34;\n&#34; vs &#34;\r\n&#34;"</title>
			<link>http://forums.leaflabs.com/topic.php?id=172#post-1143</link>
			<pubDate>Thu, 09 Sep 2010 17:50:11 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">1143@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I believe sniglen is correct. &#60;/p&#62;
&#60;p&#62;Unix (Linux, xBSD, AIX, HPUX, etc., and, AFAIK, Mac OS X) all had/have smart device drivers. The device driver is part of the kernel, and it normally decides what to do to get the effect of '\n' on those systems. &#60;/p&#62;
&#60;p&#62;As far as I can remember (I was quite young once :-), CP/M (which begat DOS, which begat Windows) did not have smart device drivers, so files contained the characters which normally drove the terminal or printer, which needed both line-feed and carriage return (only one or the other was not enough)&#60;/p&#62;
&#60;p&#62;The sneaky thing about doing a putch('\r'); putch('\n'); is that it should work correctly for both types of system.&#60;/p&#62;
&#60;p&#62;On a UNIX-ish system, and Windows, the '\r' should be interpreted as 'go back to the starting margin' (I'm ignoring the differences of which written language is in use at this point).&#60;/p&#62;
&#60;p&#62;On UNIX-ish systems, the '\n' can be safely interpreted as carriuage return (which it's just done, but UNIX tends to be very obedient, and doesn't mind doing it twice :-) followed by a line feed.&#60;/p&#62;
&#60;p&#62;On Windows, the '\n' can be interpreted as a line feed (it just did a carriage return so the cursor should be at the start of the line anyway).&#60;/p&#62;
&#60;p&#62;Clever, eh?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>snigelen on "Platform dependent use of &#34;\n&#34; vs &#34;\r\n&#34;"</title>
			<link>http://forums.leaflabs.com/topic.php?id=172#post-1110</link>
			<pubDate>Wed, 08 Sep 2010 10:59:48 +0000</pubDate>
			<dc:creator>snigelen</dc:creator>
			<guid isPermaLink="false">1110@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;For text-files it's the other way around; Unix (including Linux) traditionally use '\n' to terminate lines and Windows (and DOS) uses &#34;\r\n&#34;. But when it comes to serial communication with a terminal program they often interpret '\r' (carriage return) and '\n' (line feed) more literary. Often you can tell the terminal program what behavior you want. But &#34;\r\n&#34; seems to be default to move to the beginning of the next line with the terminal programs I used (mostly on Unix). (Maybe there's some standard in serial communication, I don't know).
&#60;/p&#62;</description>
		</item>
		<item>
			<title>StephenFromNYC on "Platform dependent use of &#34;\n&#34; vs &#34;\r\n&#34;"</title>
			<link>http://forums.leaflabs.com/topic.php?id=172#post-1107</link>
			<pubDate>Wed, 08 Sep 2010 09:09:17 +0000</pubDate>
			<dc:creator>StephenFromNYC</dc:creator>
			<guid isPermaLink="false">1107@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Wednesday September 8, 2010&#60;/p&#62;
&#60;p&#62;Hello,&#60;/p&#62;
&#60;p&#62;I was looking at the source code files located in the directory:&#60;/p&#62;
&#60;p&#62;\hardware\leaflabs\cores\maple\*.*&#60;/p&#62;
&#60;p&#62;I am probably missing something subtle.   I thought &#34;\r\n&#34; was used in Linux (and flavors of Linux, including Mac OS), but that Windows/DOS needed only &#34;\n&#34;.&#60;/p&#62;
&#60;p&#62;I was surprised when I saw &#34;\r&#34; in several files.&#60;/p&#62;
&#60;p&#62;From file: Print.cpp&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;
void Print::println(void)&#60;br /&#62;
{&#60;br /&#62;
print('\r');&#60;br /&#62;
print('\n');&#60;br /&#62;
}
&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;From file: usb.c [function void usbSendHello(void)]&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;
char *line = &#34;\r\n&#34;;
&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;From file: syscalls.c [function void cgets(char *s, int bufsize)]&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;
case '\r' :&#60;br /&#62;
case '\n' :&#60;br /&#62;
   putch('\r');&#60;br /&#62;
   putch('\n');&#60;br /&#62;
   *p = '\n';&#60;br /&#62;
return;
&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;I am using Windows XP Professional SP3 and Maple IDE 0.0.6.&#60;/p&#62;
&#60;p&#62;Thanks!&#60;/p&#62;
&#60;p&#62;Stephen from NYC
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
