# UTF-8 as default charset?

**URL:** <https://www.ruby-forum.com/t/utf-8-as-default-charset/62311>\
**Category:** Radiant CMS\
**Created:** [June 2, 2006, 5:11pm UTC](https://www.ruby-forum.com/t/utf-8-as-default-charset/62311 "2006-06-02T17:11:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![keltia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/da6949/32.png) [@keltia](https://www.ruby-forum.com/u/keltia)\
**Post date:** [June 2, 2006, 5:11pm UTC](https://www.ruby-forum.com/t/utf-8-as-default-charset/62311/1 "2006-06-02T17:11:34Z")

</div>

It seems that by default radiant/mongrel sens out HTTP headers with  
charset=“ISO-8859-1” (the standard for text/html where as I want it to  
send UTF-8 as all my pages are XHTML compliant and in UTF-8.

\<?xml version="1.0" encoding="utf-8" ?\>

in the layout doesn’t seem to make any difference.

Any idea?

---

<div class="post-metadata">

**Author:** ![keltia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/da6949/32.png) [@keltia](https://www.ruby-forum.com/u/keltia)\
**Post date:** [June 2, 2006, 9:18pm UTC](https://www.ruby-forum.com/t/utf-8-as-default-charset/62311/2 "2006-06-02T21:18:30Z")

</div>

On 6/2/06, Ollivier R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It seems that by default radiant/mongrel sens out HTTP headers with  
> charset=“ISO-8859-1” (the standard for text/html where as I want it to  
> send UTF-8 as all my pages are XHTML compliant and in UTF-8.
> 
> \<?xml version="1.0" encoding="utf-8" ?\>
> 
> in the layout doesn’t seem to make any difference.
> 
> Any idea?

Try this in the head section of your layout:

Or go into application.rb, and add this as one of the before\_filters:

def set\_charset  
@headers[“Content-Type”] = “text/html; charset=utf-8”  
end

That will probably get overwritten next time you do an svn update on  
the source tree. Maybe it’d be better to make a plugin… something  
like lib/plugins/utf8/init.rb that just modified BaseBehavior and  
forces it to send a utf8 header?

-Pawel

---

<div class="post-metadata">

**Author:** ![keltia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/da6949/32.png) [@keltia](https://www.ruby-forum.com/u/keltia)\
**Post date:** [June 6, 2006, 12:30pm UTC](https://www.ruby-forum.com/t/utf-8-as-default-charset/62311/3 "2006-06-06T12:30:15Z")

</div>

On 6/3/06, John W. Long [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Have you tried setting the content type and charset on the layout? There  
> is a new field for this in the latest version of Radiant.

Found it behind the “more…” button. Thanks, seems to work fine.

---

<div class="post-metadata">

**Author:** ![keltia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/da6949/32.png) [@keltia](https://www.ruby-forum.com/u/keltia)\
**Post date:** [June 3, 2006, 6:26am UTC](https://www.ruby-forum.com/t/utf-8-as-default-charset/62311/4 "2006-06-03T06:26:33Z")

</div>

Ollivier R. wrote:

> It seems that by default radiant/mongrel sens out HTTP headers with  
> charset=“ISO-8859-1” (the standard for text/html where as I want it to  
> send UTF-8 as all my pages are XHTML compliant and in UTF-8.
> 
> \<?xml version="1.0" encoding="utf-8" ?\>
> 
> in the layout doesn’t seem to make any difference.
> 
> Any idea?

Have you tried setting the content type and charset on the layout? There  
is a new field for this in the latest version of Radiant.

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![keltia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/da6949/32.png) [@keltia](https://www.ruby-forum.com/u/keltia)\
**Post date:** [June 8, 2006, 3:24am UTC](https://www.ruby-forum.com/t/utf-8-as-default-charset/62311/5 "2006-06-08T03:24:52Z")

</div>

Ollivier R. wrote:

> On 6/3/06, John W. Long [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Have you tried setting the content type and charset on the layout? There  
> > is a new field for this in the latest version of Radiant.
> 
> As can be seen at [http://new.keltia.net/](http://new.keltia.net/) it now works for the iste itself.
> 
> Now, how can I force the /admin/ pages to be utf-8 as well, by default,  
> for form for editing a given page is in iso8859-1 and I have to force utf-8.

Can you create a patch for this? I’m fine with the admin interface  
running on UTF-8 as long as it doesn’t cause problems for others.

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)

---

<div class="post-metadata">

**Author:** ![keltia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/da6949/32.png) [@keltia](https://www.ruby-forum.com/u/keltia)\
**Post date:** [June 7, 2006, 5:18pm UTC](https://www.ruby-forum.com/t/utf-8-as-default-charset/62311/6 "2006-06-07T17:18:07Z")

</div>

On 6/3/06, John W. Long [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Have you tried setting the content type and charset on the layout? There  
> is a new field for this in the latest version of Radiant.

As can be seen at [http://new.keltia.net/](http://new.keltia.net/) it now works for the iste  
itself.

Now, how can I force the /admin/ pages to be utf-8 as well, by default,  
for form for editing a given page is in iso8859-1 and I have to force  
utf-8.

Thanks.
