<div dir="ltr"><div>With Dancer 1 we kind of just tried to make it work, while with Dancer2 we have a much (hopefully) clearer way to handle it in the way that works with Perl:<br></div><div><br></div><div>* Decode to Perl representation when receiving input.</div><div>* Encode to UTF-8 from Perl representation when producing output.</div><div><br></div><div>Thus:</div><div>* Serializers are expected to encode by themselves.</div><div>* Template renderers also have the responsibility to encode to whatever encoding they want (usually UTF-8).</div><div><br></div><div>A few emerging guides on this matter, outside the scope of Dancer:</div><div><a href="https://github.com/rgs/p5-intelligible-unicode/">https://github.com/rgs/p5-intelligible-unicode/</a><br></div><div><a href="http://dev.perltuts.com/tutorials/unicode-introduction">http://dev.perltuts.com/tutorials/unicode-introduction</a><br></div><div><a href="https://github.com/Perl/perl5/compare/blead...rjbs/unicook">https://github.com/Perl/perl5/compare/blead...rjbs/unicook</a><br></div><div><br></div><div>I'm sure you know more on this topic than us though. :)</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 11, 2014 at 10:50 AM, Gabor Szabo <span dir="ltr"><<a href="mailto:gabor@szabgab.com" target="_blank">gabor@szabgab.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">







<p><span>I used to have this code:</span></p><p><span>sub </span><span>read_sites </span><span>{</span></p><p><span>    </span><span>open</span><span> </span><span>my</span><span> </span><span>$fh</span><span>, </span><span>'<encoding(UTF-8)'</span><span>, mymaven->{root} . </span><span>'/sites.yml'</span></p><p><span>        </span><span>or</span><span> </span><span>return</span><span> {};</span></p><p><span>    </span><span>my</span><span> </span><span>$yaml</span><span> = </span><span>do</span><span> { </span><span>local</span><span> </span><span>$/</span><span> = </span><span>undef</span><span>; <</span><span>$fh</span><span>> };</span></p><p><span>    from_yaml </span><span>$yaml</span><span>;</span></p><p>}</p><p><span>where sites.yml is this file: <a href="https://github.com/szabgab/perlmaven.com/blob/main/sites.yml" target="_blank">https://github.com/szabgab/perlmaven.com/blob/main/sites.yml</a></span></p><p><span>That worked well. Now it returns undef and does not evan complain about not being able to convert my yaml string to perl data structure.</span></p><p><span></span></p><p>=================</p><p><span>I see that in D1 from_yaml was this code:</span></p><p><span>YAML::Load(</span><span>$content</span><span>);</span></p><p>In D2 it is now this code:<br></p><p><span>YAML::Load(decode(</span><span>'UTF-8'</span><span>, </span><span>$content</span><span>));</span><br></p><p><br></p><p>So I wonder, was I doing it all wrong earlier, but it worked because of the (mis)feature of Dancer? Should I refrain from using from_yaml at all for data I read in myself?</p><p>What was the recommended approach here for D1 and what is it for D2?</p><span class="HOEnZb"><font color="#888888"><p>Gabor</p></font></span><div>ps. Now that I saw this code, I am going to convert it to Path::Tiny, but I think the reason I have not used it earlier was that the 'path' function of that module and the 'path' function of Dancer would clash.</div><div></div>
</div>
<br>_______________________________________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
<br></blockquote></div></div>