<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/rss-style.css?cache=2026-11-11T18:23" type="text/css"?>
<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/"
	>
<html:meta xmlns:html="http://www.w3.org/1999/xhtml" name="viewport" content="initial-scale=1" />
<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>
	<copyright>© Terence Eden. 🄯 CC BY-SA. See https://shkspr.mobi/blog/copyright-and-copyleft/</copyright>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.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[Terence Eden]]></dc:creator>
		<pubDate>Wed, 17 Feb 2010 11:45:21 +0000</pubDate>
		<category><![CDATA[aral]]></category><category><![CDATA[dabr]]></category><category><![CDATA[feathers]]></category><category><![CDATA[HTML]]></category><category><![CDATA[mobile]]></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>&lt;p&gt;As any student of computer science knows, &lt;a href="http://en.wikipedia.org/wiki/Newline"&gt;line breaks are confusing&lt;/a&gt;. 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?&lt;/p&gt;

&lt;p&gt;This was a problem I faced when trying to get Dabr to render the &lt;a href="http://en.wikipedia.org/wiki/ASCII_art"&gt;ASCII art&lt;/a&gt;&lt;sup id="fnref:ascii"&gt;&lt;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"&gt;0&lt;/a&gt;&lt;/sup&gt; produced by &lt;a href="http://aralbalkan.com/"&gt;Aral Balkan&lt;/a&gt;'s &lt;a href="https://web.archive.org/web/20100215193137/https://feathersapp.com/"&gt;Feathers App&lt;/a&gt;.  Feathers uses line breaks to achieve images like...&lt;/p&gt;

&lt;pre&gt;〰❀❃ Introducing ❃❀〰
My new iPhone app,
░░░▒█ Feathers █▒░░░
&lt;/pre&gt;

&lt;p&gt;What's confusing to me, as a developer is the inconsistent way Twitter handles line breaks.  For example...&lt;/p&gt;

&lt;p&gt;Twitter's website ignores line breaks.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;div id="attachment_1643-2" style="width: 410px" class="wp-caption aligncenter"&gt;&lt;img aria-describedby="caption-attachment-1643-2" 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"&gt;&lt;p id="caption-attachment-1643-2" class="wp-caption-text"&gt;Desktop Spacing&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Twitter Mobile, however, does line breaking correctly.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;&lt;div id="attachment_1644-2" style="width: 330px" class="wp-caption aligncenter"&gt;&lt;img aria-describedby="caption-attachment-1644-2" 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"&gt;&lt;p id="caption-attachment-1644-2" class="wp-caption-text"&gt;Android Spacing&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;

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

&lt;p&gt;In my opinion, &lt;strong&gt;respect the user&lt;/strong&gt;. 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).&lt;/p&gt;

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

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

&lt;div id="footnotes" role="doc-endnotes"&gt;
&lt;hr aria-label="Footnotes"&gt;
&lt;ol start="0"&gt;

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

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