<?xml version="1.0" encoding="UTF-8"?>
<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>Maxim Kim: Blog &#187; ruby</title>
	<atom:link href="http://habamax.ru/blog/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://habamax.ru/blog</link>
	<description></description>
	<lastBuildDate>Tue, 24 Aug 2010 18:53:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Как создать файл с Unix newline в Ruby для Windows?</title>
		<link>http://habamax.ru/blog/2009/01/%d0%ba%d0%b0%d0%ba-%d1%81%d0%be%d0%b7%d0%b4%d0%b0%d1%82%d1%8c-%d1%84%d0%b0%d0%b9%d0%bb-%d1%81-unix-newline-%d0%b2-ruby-%d0%b4%d0%bb%d1%8f-windows/</link>
		<comments>http://habamax.ru/blog/2009/01/%d0%ba%d0%b0%d0%ba-%d1%81%d0%be%d0%b7%d0%b4%d0%b0%d1%82%d1%8c-%d1%84%d0%b0%d0%b9%d0%bb-%d1%81-unix-newline-%d0%b2-ruby-%d0%b4%d0%bb%d1%8f-windows/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 07:33:50 +0000</pubDate>
		<dc:creator>Maxim Kim</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://habamax.ru/blog/?p=217</guid>
		<description><![CDATA[Казалось бы, что может быть проще? f = File.new(&#34;d:/tmp/test.txt&#34;, &#34;w&#34;) f.print &#34;Line 1 with CRLF line ending.\n&#34; f.print &#34;Line 2 with CRLF line ending.\n&#34; f.print &#34;Line 3 with CRLF line ending.\n&#34; f.close Однако в файл запишутся CRLF&#8217;ы (\r\n), потому как \n, использованный в f.print&#8216;е, в Ruby зависит от платформы. А вот если открыть файл в [...]]]></description>
			<content:encoded><![CDATA[<p>Казалось бы, что может быть проще?</p>
<pre class="brush: ruby;">
f = File.new(&quot;d:/tmp/test.txt&quot;, &quot;w&quot;)
f.print &quot;Line 1 with CRLF line ending.\n&quot;
f.print &quot;Line 2 with CRLF line ending.\n&quot;
f.print &quot;Line 3 with CRLF line ending.\n&quot;
f.close
</pre>
<p>Однако в файл запишутся CRLF&#8217;ы (<code>\r\n</code>), потому как <code>\n</code>, использованный в <code>f.print</code>&#8216;е, в Ruby зависит от платформы.<br />
А вот если открыть файл в binary режиме, то все будет шоколадно:</p>
<pre class="brush: ruby">
f = File.new(&quot;d:/tmp/test.txt&quot;, &quot;wb&quot;)
f.print &quot;Line 1 with LF line ending.\n&quot;
f.print &quot;Line 2 with LF line ending.\n&quot;
f.print &quot;Line 3 with LF line ending.\n&quot;
f.close
</pre>
]]></content:encoded>
			<wfw:commentRss>http://habamax.ru/blog/2009/01/%d0%ba%d0%b0%d0%ba-%d1%81%d0%be%d0%b7%d0%b4%d0%b0%d1%82%d1%8c-%d1%84%d0%b0%d0%b9%d0%bb-%d1%81-unix-newline-%d0%b2-ruby-%d0%b4%d0%bb%d1%8f-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
