<?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>NiceCabbage Blog &#187; yaml</title>
	<atom:link href="http://www.nicecabbage.com/tag/yaml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nicecabbage.com</link>
	<description>Life, Design, Web Application</description>
	<lastBuildDate>Mon, 07 Jun 2010 02:03:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Dump YAML Strings with UTF-8 multibyte characters in Ruby</title>
		<link>http://www.nicecabbage.com/2009/06/dump-yaml-string-with-utf8-multibyte-characters/</link>
		<comments>http://www.nicecabbage.com/2009/06/dump-yaml-string-with-utf8-multibyte-characters/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 11:21:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[TechTips]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[yaml]]></category>

		<guid isPermaLink="false">http://www.nicecabbage.com/?p=84</guid>
		<description><![CDATA[Problem
You want to dump your Ruby object to YAML-formatted file, but your object contains UTF-8 multibyte characters. In this situation, original yaml dumper will output in a human-unfriendly format like

  - !binary &#124;
   5a6X6LC35bKs

Solution
The easiest way to solve is to use ya2yaml.

 sudo gem install ya2yaml

Then, in your source code,

open&#40;&#34;save.yml&#34;, &#34;w&#34;&#41; do [...]]]></description>
			<content:encoded><![CDATA[<h2>Problem</h2>
<p>You want to dump your Ruby object to YAML-formatted file, but your object contains UTF-8 multibyte characters. In this situation, original yaml dumper will output in a human-unfriendly format like</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#006600; font-weight:bold;">-</span> !binary <span style="color:#006600; font-weight:bold;">|</span>
   5a6X6LC35bKs</pre></div></div>

<h2>Solution</h2>
<p>The easiest way to solve is to use <a href="http://rubyforge.org/projects/ya2yaml/">ya2yaml</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> ya2yaml</pre></div></div>

<p>Then, in your source code,</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;save.yml&quot;</span>, <span style="color:#996600;">&quot;w&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> 
 f.<span style="color:#9900CC;">write</span> multiByteObj.<span style="color:#9900CC;">ya2yaml</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.nicecabbage.com/2009/06/dump-yaml-string-with-utf8-multibyte-characters/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
