<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("UTF-8", 'my text' ).<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> $c->res->header( 'Cache-Control' => 'public, max-age=600' ); <br>
my $fh = $c->res->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">"All that is necessary </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"> is for good men to do nothing". -- 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"><<a href="mailto:bobtfish@bobtfish.net" target="_blank">bobtfish@bobtfish.net</a>></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. <<a href="mailto:dim0xff@gmail.com" target="_blank">dim0xff@gmail.com</a>> wrote:<br>
<br>
> use utf8;<br>
<br>
You shouldn’t need this unless you have actual utf8 characters (rather than escapes) in your source code.<br>
<div><br>
> my $fh = $c->res->write_fh;<br>
> my $test = "\x{41f}\x{440}\x{43e}\x{431}\x{430}";<br>
> utf8::encode($test);<br>
<br>
</div>You probably actually want Encode::encode(‘UTF-8’, $test);<br>
<div><br>
> $fh->write($test);<br>
><br>
> On 20 February 2014 17:45, Sergey Dmitriev <<a href="mailto:sergey.programmer@gmail.com" target="_blank">sergey.programmer@gmail.com</a>> wrote:<br>
>> Hello,<br>
>><br>
>> I'm trying to put some utf8 strings as a part of Catalyst response as<br>
>> follows:<br>
>><br>
<br>
</div>Right, you can’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>
>> $c->res->print ( ... )<br>
>> and<br>
>> $c->res->write( ... )<br>
>><br>
>> line by line.<br>
>><br>
>> However it dies with<br>
>><br>
>> Wide character in syswrite at ..... IO/Handle.pm line 474<br>
>><br>
>> Any ideas how can utf8 be written to response?<br>
>><br>
>> E.g. set binmode on output handle. Cannot find how.<br>
>> Using Catalyst Runtime 5.90042.<br>
>><br>
<br>
</div>This is not what you want to do.<br>
<br>
The handle is already binary - just you’re not writing binary to it, you’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>