<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/rss-style.xsl" type="text/xsl"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	     xmlns:dc="http://purl.org/dc/elements/1.1/"
	   xmlns:atom="http://www.w3.org/2005/Atom"
	     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	  xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>feathers &#8211; Terence Eden’s Blog</title>
	<atom:link href="https://shkspr.mobi/blog/tag/feathers/feed/" rel="self" type="application/rss+xml" />
	<link>https://shkspr.mobi/blog</link>
	<description>Regular nonsense about tech and its effects 🙃</description>
	<lastBuildDate>Tue, 17 Feb 2026 10:18:28 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://shkspr.mobi/blog/wp-content/uploads/2023/07/cropped-avatar-32x32.jpeg</url>
	<title>feathers &#8211; Terence Eden’s Blog</title>
	<link>https://shkspr.mobi/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title><![CDATA[Twitter and Linebreaks]]></title>
		<link>https://shkspr.mobi/blog/2010/02/twitter-and-linebreaks/</link>
					<comments>https://shkspr.mobi/blog/2010/02/twitter-and-linebreaks/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Wed, 17 Feb 2010 11:45:21 +0000</pubDate>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[aral]]></category>
		<category><![CDATA[dabr]]></category>
		<category><![CDATA[feathers]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[twitter]]></category>
		<guid isPermaLink="false">http://shkspr.mobi/blog/?p=1642</guid>

					<description><![CDATA[As any student of computer science knows, line breaks are confusing. There are styles of line breaks unique to Unix, Mac and Windows - so what should a web renderer do when faced with a newline command?  In HTML, it&#039;s simple, they should be ignored.  But what when it is user generated text, not HTML?  This was a problem I faced when trying to get Dabr to render the ASCII art produced by Aral…]]></description>
										<content:encoded><![CDATA[<p>As any student of computer science knows, <a href="http://en.wikipedia.org/wiki/Newline">line breaks are confusing</a>. There are styles of line breaks unique to Unix, Mac and Windows - so what should a web renderer do when faced with a newline command?  In HTML, it's simple, they should be ignored.  But what when it is user generated text, not HTML?</p>

<p>This was a problem I faced when trying to get Dabr to render the <a href="http://en.wikipedia.org/wiki/ASCII_art">ASCII art</a><sup id="fnref:ascii"><a href="https://shkspr.mobi/blog/2010/02/twitter-and-linebreaks/#fn:ascii" class="footnote-ref" title="Technically, Unicode Art. But that doesn't have the same ring to it." role="doc-noteref">0</a></sup> produced by <a href="http://aralbalkan.com/">Aral Balkan</a>'s <a href="https://web.archive.org/web/20100215193137/https://feathersapp.com/">Feathers App</a>.  Feathers uses line breaks to achieve images like...</p>

<pre>〰❀❃ Introducing ❃❀〰
My new iPhone app,
░░░▒█ Feathers █▒░░░
</pre>

<p>What's confusing to me, as a developer is the inconsistent way Twitter handles line breaks.  For example...</p>

<p>Twitter's website ignores line breaks.</p>

<p></p><div id="attachment_1643" style="width: 410px" class="wp-caption aligncenter"><img aria-describedby="caption-attachment-1643" class="size-full wp-image-1643" title="Desktop Spacing" src="https://shkspr.mobi/blog/wp-content/uploads/2010/02/Desktop-Spacing.png" alt="Desktop Spacing" width="400" height="178"><p id="caption-attachment-1643" class="wp-caption-text">Desktop Spacing</p></div><p></p>

<p>Twitter Mobile, however, does line breaking correctly.</p>

<p></p><div id="attachment_1644" style="width: 330px" class="wp-caption aligncenter"><img aria-describedby="caption-attachment-1644" class="size-full wp-image-1644" title="Android Spacing" src="https://shkspr.mobi/blog/wp-content/uploads/2010/02/Android-Spacing.png" alt="Android Spacing" width="320" height="480"><p id="caption-attachment-1644" class="wp-caption-text">Android Spacing</p></div><p></p>

<p>Twitter has no style guide for rendering and - if it did - appears to render inconsistently.  So, what's the correct thing to do?</p>

<p>In my opinion, <strong>respect the user</strong>. If a user has indicted that they want something, it is a developer's role to implement it (unless it causes severe problems for the system).</p>

<h2 id="how-to-achieve-it"><a href="https://shkspr.mobi/blog/2010/02/twitter-and-linebreaks/#how-to-achieve-it">How to achieve it?</a></h2>

<p>You could use all sorts of complex regular expressions to get line breaks and convert them.
Thankfully, PHP has this function built in with <a href="http://uk.php.net/manual/en/function.nl2br.php">nl2br()</a> which will give you (X)HTML line breaks wherever a break occurs in the text.</p>

<div id="footnotes" role="doc-endnotes">
<hr aria-label="Footnotes">
<ol start="0">

<li id="fn:ascii">
<p>Technically, Unicode Art. But that doesn't have the same ring to it.&nbsp;<a href="https://shkspr.mobi/blog/2010/02/twitter-and-linebreaks/#fnref:ascii" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>

</ol>
</div>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=1642&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2010/02/twitter-and-linebreaks/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
			</item>
	</channel>
</rss>
