# Setting custom encoding for a single request?

**URL:** <https://www.ruby-forum.com/t/setting-custom-encoding-for-a-single-request/185580>\
**Category:** Rails\
**Created:** [March 23, 2010, 3:55am UTC](https://www.ruby-forum.com/t/setting-custom-encoding-for-a-single-request/185580 "2010-03-23T03:55:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![donncha](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/90db22/32.png) [@donncha](https://www.ruby-forum.com/u/donncha)\
**Post date:** [March 23, 2010, 3:55am UTC](https://www.ruby-forum.com/t/setting-custom-encoding-for-a-single-request/185580/1 "2010-03-23T03:55:30Z")

</div>

Hi all,

I was wondering if it’s possible to set Rails’s output encoding for a  
single request w/ Ruby 1.9?

For example, one request on my app generates a form for submission to a  
third-party who mandates ISO-8859-1, and the form therefore contains  
iso-8859-1 encoded strings.

Although I set the response’s content-type to ‘text/html;  
charset=ISO-8859-1’, when Rails renders the output it produces a UTF-8  
string (containing ISO-8859-1 characters) and then falls over with an  
“ArgumentError (invalid byte sequence in UTF-8)”.

Is is possible to tell Rails "generate all output for this request in  
charset x?’

thanks,  
d
