# How to change the response charset

**URL:** <https://www.ruby-forum.com/t/how-to-change-the-response-charset/165001>\
**Category:** Rails\
**Created:** [April 8, 2009, 6:46am UTC](https://www.ruby-forum.com/t/how-to-change-the-response-charset/165001 "2009-04-08T06:46:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xabriel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/3da27b/32.png) [@xabriel](https://www.ruby-forum.com/u/xabriel)\
**Post date:** [April 8, 2009, 6:46am UTC](https://www.ruby-forum.com/t/how-to-change-the-response-charset/165001/1 "2009-04-08T06:46:12Z")

</div>

Hi all,

I have the following on a controller method:

render :text =\> “A string message”

I want that response body to be converted to US-ASCII. (BTW, Ruby  
seems to default to UTF-8)

Any ideas? I know theres a ‘response.charset’, but that seems to only  
change the response’s charset header. I need the actual body string to  
be changed to US-ASCII.

---

<div class="post-metadata">

**Author:** ![xabriel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/3da27b/32.png) [@xabriel](https://www.ruby-forum.com/u/xabriel)\
**Post date:** [April 8, 2009, 7:23pm UTC](https://www.ruby-forum.com/t/how-to-change-the-response-charset/165001/2 "2009-04-08T19:23:25Z")

</div>

Well, I fixed this issue following Charset conversion rules from this  
blog post:  
[http://blog.grayproductions.net/articles/encoding\_conversion\_with\_iconv](http://blog.grayproductions.net/articles/encoding_conversion_with_iconv)

James (the blog author) actually has the most comprehensive treatment  
on Ruby Strings (both for 1.8 & 1.9).

Hope this helps somebody someday! 🙂

---

<div class="post-metadata">

**Author:** ![xabriel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/3da27b/32.png) [@xabriel](https://www.ruby-forum.com/u/xabriel)\
**Post date:** [April 8, 2009, 7:24pm UTC](https://www.ruby-forum.com/t/how-to-change-the-response-charset/165001/3 "2009-04-08T19:24:01Z")

</div>

Well, I fixed this issue following Charset conversion rules from this  
blog post:  
[http://blog.grayproductions.net/articles/encoding\_conversion\_with\_iconv](http://blog.grayproductions.net/articles/encoding_conversion_with_iconv)

James (the blog author) actually has the most comprehensive treatment  
on Ruby Strings (both for 1.8 & 1.9).

Hope this helps somebody someday! 🙂
