<div dir="ltr"><div><div><div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">Thank you, it works! by using Encode::encode(&quot;UTF-8&quot;, &#39;my text&#39; ).<br>

</blockquote><br></div><div>And just for reference, if anyone will use it, HTTP headers should be set BEFORE calling write_fh.<br>e.g.<br>&nbsp;&nbsp;&nbsp; $c-&gt;res-&gt;header( &#39;Cache-Control&#39;&nbsp; =&gt; &#39;public, max-age=600&#39; ); <br>

&nbsp;&nbsp;&nbsp; my $fh = $c-&gt;res-&gt;write_fh; # psgi writer, not filehandle<br><br></div><div>Otherwise headers will not be set.<br></div></div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><div>HtH, Sergey Dmitriev</div>

<div><i><span style="color:rgb(68,68,68);font-size:small;line-height:16px">&quot;All that is necessary&nbsp;</span><span style="color:rgb(68,68,68);font-size:small;line-height:16px">for evil to triumph</span><span style="color:rgb(68,68,68);font-size:small;line-height:16px">&nbsp;is for good men to do nothing&quot;. -- Edmund Burke</span></i><br>


</div></div></div>
<br><br><div class="gmail_quote">2014-02-20 18:53 GMT+04:00 Tomas Doran <span dir="ltr">&lt;<a href="mailto:bobtfish@bobtfish.net" target="_blank">bobtfish@bobtfish.net</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">


<br>
On Feb 20, 2014, at 2:19 PM, Dmitry L. &lt;<a href="mailto:dim0xff@gmail.com" target="_blank">dim0xff@gmail.com</a>&gt; wrote:<br>
<br>
&gt; &nbsp; &nbsp;use utf8;<br>
<br>
You shouldn&rsquo;t need this unless you have actual utf8 characters (rather than escapes) in your source code.<br>
<div><br>
&gt; &nbsp; &nbsp;my $fh = $c-&gt;res-&gt;write_fh;<br>
&gt; &nbsp; &nbsp;my $test = &quot;\x{41f}\x{440}\x{43e}\x{431}\x{430}&quot;;<br>
&gt; &nbsp; &nbsp;utf8::encode($test);<br>
<br>
</div>You probably actually want Encode::encode(&lsquo;UTF-8&rsquo;, $test);<br>
<div><br>
&gt; &nbsp; &nbsp;$fh-&gt;write($test);<br>
&gt;<br>
&gt; On 20 February 2014 17:45, Sergey Dmitriev &lt;<a href="mailto:sergey.programmer@gmail.com" target="_blank">sergey.programmer@gmail.com</a>&gt; wrote:<br>
&gt;&gt; Hello,<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m trying to put some utf8 strings as a part of Catalyst response as<br>
&gt;&gt; follows:<br>
&gt;&gt;<br>
<br>
</div>Right, you can&rsquo;t do that :)<br>
<br>
If you try to use the raw write interfaces you have to send bytes not characters (and so need to encode your utf8 character strings).<br>
<div><br>
&gt;&gt; $c-&gt;res-&gt;print ( ... )<br>
&gt;&gt; and<br>
&gt;&gt; $c-&gt;res-&gt;write( ... )<br>
&gt;&gt;<br>
&gt;&gt; line by line.<br>
&gt;&gt;<br>
&gt;&gt; However it dies with<br>
&gt;&gt;<br>
&gt;&gt; &nbsp; Wide character in syswrite at ..... IO/Handle.pm line 474<br>
&gt;&gt;<br>
&gt;&gt; Any ideas how can utf8 be written to response?<br>
&gt;&gt;<br>
&gt;&gt; E.g. set binmode on output handle. Cannot find how.<br>
&gt;&gt; Using Catalyst Runtime 5.90042.<br>
&gt;&gt;<br>
<br>
</div>This is not what you want to do.<br>
<br>
The handle is already binary - just you&rsquo;re not writing binary to it, you&rsquo;re writing characters (and perl does not know how to translate those characters into bytes).<br>
<br>
Cheers<br>
Tom<br>
<div><div><br>
<br>
_______________________________________________<br>
List: <a href="mailto:Catalyst@lists.scsys.co.uk" target="_blank">Catalyst@lists.scsys.co.uk</a><br>
Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst" target="_blank">http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst</a><br>
Searchable archive: <a href="http://www.mail-archive.com/catalyst@lists.scsys.co.uk/" target="_blank">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a><br>
Dev site: <a href="http://dev.catalyst.perl.org/" target="_blank">http://dev.catalyst.perl.org/</a><br>
</div></div></blockquote></div><br></div></div>