[dancer-users] Failing to send a file in iso-8859-1

Peter Mottram peter at sysnix.com
Thu Oct 6 14:32:05 BST 2016


On 06/10/16 15:03, Stefan Hornburg (Racke) wrote:
> On 10/06/2016 02:56 PM, Lutz Gehlen wrote:
>> Hi Gunnar,
>>
>> thank you for your reply.
>>
>> On Wednesday 05.10.2016 20:58:22 WK wrote:
>>> 2016-10-05 19:59 GMT+03:00 Lutz Gehlen <lrg_ml at gmx.net>:
>>>> send_file(
>>>>
>>>>     \$str,
>>>>     content_type => 'text/csv',
>>>>     filename     => 'foo.csv',
>>>>
>>>> );
>>>>
>>>> The problem is that external requirements force me to send the file
>>>> in iso-8859-1 and it seems that I cannot manage to achieve that.
>>> As far as I understand, the charset is set in config, so you could try
>>> to override the setting in your route like:
>>>
>>> set 'charset'      => 'iso-8859-1;
>>>
>>> Never tried, but it should work.
>> Yes. this works. However, it changes charset permanently (for the current 
>> process) and I don't get the chance to change it back because send_file does 
>> not return. Is there no way to set it temporarily just for this send_file?
> Hello Lutz,
>
> you could (re)set the charset in the "before" hook to the normal one.
>
> Regards
>          Racke
>
There ought to be a way to set charset as an option to send_file.

I've created an issue: https://github.com/PerlDancer/Dancer2/issues/1260

Lutz: could you please check this issue and add further comment if
needed? Also let us know if you'd like to have a go at a PR. If not I'll
create a patch.

R.
PeteM





More information about the dancer-users mailing list