<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hmmm,<div><br></div><div>That looks fine by itself.</div><div><br></div><div>Could you put a test case together in a minimal catalyst app for other ppl to try?</div><div><br></div><div>-ash</div><div><br><div><div>On 24 May 2008, at 10:12, Martin Ellison wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Ash,<br><br><div style="margin-left: 40px;">&nbsp;<span style="font-family: courier new,monospace;">&nbsp;&nbsp; my $pic_image = $p->ImageToBlob();</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; $c->res->content_type(q{image/jpeg});</span><br style="font-family: courier new,monospace;"> <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; $c->res->header( 'Content-Disposition', q{inline} );</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; $c->res->body($pic_image);</span><br> </div><br>$p is an ImageMagick picture object which is creating a byte sequence representing a JPEG image (<span style="font-family: courier new,monospace;">$pic_image</span>).&nbsp; I have set the output to Unicode using the Unicode plugin. This is going into an &lt;img> tag.<br> <br><div class="gmail_quote">2008/5/23 Ash Berlin &lt;<a href="mailto:ash_cpan@firemirror.com">ash_cpan@firemirror.com</a>>:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <div style="">You're going to have to paste some code I've been happily serving up PDFs (which has all sorts of binary data in it) fine.<div><br></div><div>1) How are you serving the file up?</div><div>2) What headers are you setting?</div> <div><br></div><div>-ash</div><div><br><div><div><div></div><div class="Wj3C7c"><div>On 23 May 2008, at 16:00, Martin Ellison wrote:</div><br></div></div><blockquote type="cite"><div><div></div><div class="Wj3C7c">Another case... the surrogate is d862 = 55394 but the image size is 45296, so it is not looking consistent. So perhaps the 'surrogate' data is just random bytes from the JPEG.<br> <br><div class="gmail_quote">2008/5/23 Martin Ellison &lt;<a href="mailto:m.e@acm.org" target="_blank">m.e@acm.org</a>>:<br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> I've found a case<br><div style="margin-left: 40px;"><span style="font-family: courier new,monospace;">...stderr: UTF-16 surrogate 0xdb71 at /usr/lib/perl/5.8/IO/Handle.pm line 199...</span><br style="font-family: courier new,monospace;"> <span style="font-family: courier new,monospace;">FastCGI: ... [info] picture size is 55966</span><br></div><br>55966 = da9e<br>56177 = db71 <br>&nbsp;<br>So almost the same. Perhaps I have 100 bytes of headers.<br><br><br><div class="gmail_quote"> 2008/5/20 Martin Ellison &lt;<a href="mailto:m.e@acm.org" target="_blank">m.e@acm.org</a>>:<div><div></div><div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> The Content-Type is set to 'UTF-8' for most of my pages, but, in this case, it is image/jpeg and the content disposition is set to inline.<br> <br><div class="gmail_quote">2008/5/19 Ash Berlin &lt;<a href="mailto:ash_cpan@firemirror.com" target="_blank">ash_cpan@firemirror.com</a>>:<div> <div></div><div><br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div>On 19 May 2008, at 12:34, Martin Ellison wrote:<br> <br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> I've finally had the opportunity to test my code a bit more. The $pic_image is a string of some kind and not a file handle.<br> <br> Also I tried doing binmode STDOUT but this fails -- &nbsp;the binmode call returns false.<br> <br> There could be any binary data in my string, so any UTF-8-bad byte pairs are definitely possible. I would think the solution is to inform Catalyst that the data is not UTF-8 but binary. In the normal case of writing to a file, one can use binmode to tell perl that the data is binary but that does not work here.<br> <br> Is this a gap in the Catalyst API?<br> </blockquote> <br></div> Are you by any chance setting a header to something with UTF8 content?<br> <br> I had a problem similar to this that was caused by me setting a Content-Disposition header to something including unicode.<br> <font color="#888888"> <br> -ash</font><div><div></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></div></div><br><br clear="all"><div><div></div><div><br>-- <br>Regards,<br>Martin<br> (<a href="mailto:m.e@acm.org" target="_blank">m.e@acm.org</a>)<br>IT: <a href="http://methodsupport.com" target="_blank">http://methodsupport.com</a> Personal: <a href="http://thereisnoend.org" target="_blank">http://thereisnoend.org</a> </div> </div></blockquote></div></div></div><div><div></div><div><br><br clear="all"><br>-- <br>Regards,<br>Martin<br>(<a href="mailto:m.e@acm.org" target="_blank">m.e@acm.org</a>)<br>IT: <a href="http://methodsupport.com" target="_blank">http://methodsupport.com</a> Personal: <a href="http://thereisnoend.org" target="_blank">http://thereisnoend.org</a> </div> </div></blockquote></div><br><br clear="all"><br>-- <br>Regards,<br>Martin<br>(<a href="mailto:m.e@acm.org" target="_blank">m.e@acm.org</a>)<br></div></div>IT: <a href="http://methodsupport.com" target="_blank">http://methodsupport.com</a> Personal: <a href="http://thereisnoend.org" target="_blank">http://thereisnoend.org</a> _______________________________________________<div class="Ih2E3d"> <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></blockquote></div><br></div></div><br>_______________________________________________<br> List: <a href="mailto:Catalyst@lists.scsys.co.uk">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> <br></blockquote></div><br><br clear="all"><br>-- <br>Regards,<br>Martin<br>(<a href="mailto:m.e@acm.org">m.e@acm.org</a>)<br>IT: <a href="http://methodsupport.com">http://methodsupport.com</a> Personal: <a href="http://thereisnoend.org">http://thereisnoend.org</a> _______________________________________________<br>List: <a href="mailto:Catalyst@lists.scsys.co.uk">Catalyst@lists.scsys.co.uk</a><br>Listinfo: <a href="http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst">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/">http://www.mail-archive.com/catalyst@lists.scsys.co.uk/</a><br>Dev site: <a href="http://dev.catalyst.perl.org/">http://dev.catalyst.perl.org/</a><br></blockquote></div><br></div></body></html>