[Catalyst] UTF-16 surrogate message when writing binary data(image)

Ash Berlin ash_cpan at firemirror.com
Sat May 24 10:43:11 BST 2008


Hmmm,

That looks fine by itself.

Could you put a test case together in a minimal catalyst app for other  
ppl to try?

-ash

On 24 May 2008, at 10:12, Martin Ellison wrote:

> Ash,
>
>     my $pic_image = $p->ImageToBlob();
>     $c->res->content_type(q{image/jpeg});
>     $c->res->header( 'Content-Disposition', q{inline} );
>     $c->res->body($pic_image);
>
> $p is an ImageMagick picture object which is creating a byte  
> sequence representing a JPEG image ($pic_image).  I have set the  
> output to Unicode using the Unicode plugin. This is going into an  
> <img> tag.
>
> 2008/5/23 Ash Berlin <ash_cpan at firemirror.com>:
> 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.
>
> 1) How are you serving the file up?
> 2) What headers are you setting?
>
> -ash
>
> On 23 May 2008, at 16:00, Martin Ellison wrote:
>
>> 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.
>>
>> 2008/5/23 Martin Ellison <m.e at acm.org>:
>> I've found a case
>> ...stderr: UTF-16 surrogate 0xdb71 at /usr/lib/perl/5.8/IO/ 
>> Handle.pm line 199...
>> FastCGI: ... [info] picture size is 55966
>>
>> 55966 = da9e
>> 56177 = db71
>>
>> So almost the same. Perhaps I have 100 bytes of headers.
>>
>>
>> 2008/5/20 Martin Ellison <m.e at acm.org>:
>>
>> 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.
>>
>> 2008/5/19 Ash Berlin <ash_cpan at firemirror.com>:
>>
>> On 19 May 2008, at 12:34, Martin Ellison wrote:
>>
>> 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.
>>
>> Also I tried doing binmode STDOUT but this fails --  the binmode  
>> call returns false.
>>
>> 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.
>>
>> Is this a gap in the Catalyst API?
>>
>> Are you by any chance setting a header to something with UTF8  
>> content?
>>
>> I had a problem similar to this that was caused by me setting a  
>> Content-Disposition header to something including unicode.
>>
>> -ash
>>
>>
>> _______________________________________________
>> List: Catalyst at lists.scsys.co.uk
>> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
>> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
>> Dev site: http://dev.catalyst.perl.org/
>>
>>
>>
>> -- 
>> Regards,
>> Martin
>> (m.e at acm.org)
>> IT: http://methodsupport.com Personal: http://thereisnoend.org
>>
>>
>>
>> -- 
>> Regards,
>> Martin
>> (m.e at acm.org)
>> IT: http://methodsupport.com Personal: http://thereisnoend.org
>>
>>
>>
>> -- 
>> Regards,
>> Martin
>> (m.e at acm.org)
>> IT: http://methodsupport.com Personal: http://thereisnoend.org  
>> _______________________________________________
>>
>> List: Catalyst at lists.scsys.co.uk
>> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
>> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
>> Dev site: http://dev.catalyst.perl.org/
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>
>
>
> -- 
> Regards,
> Martin
> (m.e at acm.org)
> IT: http://methodsupport.com Personal: http://thereisnoend.org  
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20080524/4e6286f2/attachment.htm


More information about the Catalyst mailing list