# UTF-8 problem

**URL:** <https://www.ruby-forum.com/t/utf-8-problem/72347>\
**Category:** Radiant CMS\
**Created:** [October 16, 2006, 6:04pm UTC](https://www.ruby-forum.com/t/utf-8-problem/72347 "2006-10-16T18:04:38Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![p0pnfresh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7cd45c/32.png) [@p0pnfresh](https://www.ruby-forum.com/u/p0pnfresh)\
**Post date:** [October 16, 2006, 6:04pm UTC](https://www.ruby-forum.com/t/utf-8-problem/72347/1 "2006-10-16T18:04:38Z")

</div>

Hi,

I’m developing a website locally using Radiant.

I’ve installed mysql using UTF-8 as the default charset.  
If I run \s in the mysql command line it shows eveything is set to  
UTF-8.  
I’m using Navicat to manage Mysql, which also has UTF-8 as the default  
charset.  
I’ve also included between my Normal layout head tags.

And I’ve read the following related thread  
[http://lists.radiantcms.org/pipermail/radiant/2006-June/000442.html](http://lists.radiantcms.org/pipermail/radiant/2006-June/000442.html)

The problem is, that when I write to the database using Radiant’s admin  
back end, the accented characters (á,é,í,ó,ú) and the spanish letter ñ  
appear scrambled in the mysql database. The chracters do render properly  
in the browser via Radiant, although they don’t in the mysql database.  
And  
if I export my mysql database the characters appear scrambled.

: (

I appreciate any help.

Jose.

---

<div class="post-metadata">

**Author:** ![p0pnfresh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7cd45c/32.png) [@p0pnfresh](https://www.ruby-forum.com/u/p0pnfresh)\
**Post date:** [October 16, 2006, 10:06pm UTC](https://www.ruby-forum.com/t/utf-8-problem/72347/2 "2006-10-16T22:06:27Z")

</div>

Does it make a difference if you set the content-type as part of the  
page\_headers hash?

On 10/16/06, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

–  
Alexander H.  
[http://www2.truman.edu/~ah428](http://www2.truman.edu/~ah428)

---

<div class="post-metadata">

**Author:** ![p0pnfresh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7cd45c/32.png) [@p0pnfresh](https://www.ruby-forum.com/u/p0pnfresh)\
**Post date:** [October 16, 2006, 10:47pm UTC](https://www.ruby-forum.com/t/utf-8-problem/72347/3 "2006-10-16T22:47:16Z")

</div>

Hi,

Are you refering to the MORE link in the NORMAL Layout’s section? If so,  
I’ve already set it to UTF-8 and it makes no difference.

My question would be.

Where do I specify what character encoding to use in the admin backend  
when writing to the database? The NORMAL layout charset, I suppose,  
refers  
to the output rendered on the front end (website). What I want to know  
is  
if Radiant has a charset declared when writing to mysql?

Hope I’m making sense.  
Thanks in advance.

Jose.

---

<div class="post-metadata">

**Author:** ![p0pnfresh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7cd45c/32.png) [@p0pnfresh](https://www.ruby-forum.com/u/p0pnfresh)\
**Post date:** [October 16, 2006, 11:49pm UTC](https://www.ruby-forum.com/t/utf-8-problem/72347/4 "2006-10-16T23:49:45Z")

</div>

> What I want to know is if Radiant has a charset declared when writing to mysql?

Radiant does not control the charset when writing to the database.  
That’s a good question though. I haven’t ever seen a Rails app  
actually doing that type of stuff.

On 10/16/06, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> if Radiant has a charset declared when writing to mysql?
> 
> > > Hi,
> > > 
> > > Search: [http://radiantcms.org/mailing-list/search/](http://radiantcms.org/mailing-list/search/)  
> > > Search: [http://radiantcms.org/mailing-list/search/](http://radiantcms.org/mailing-list/search/)  
> > > Site: [http://lists.radiantcms.org/mailman/listinfo/radiant](http://lists.radiantcms.org/mailman/listinfo/radiant)
> 
> * * *
> 
> Radiant mailing list  
> Post: removed\_email\_address@domain.invalid  
> Search: [http://radiantcms.org/mailing-list/search/](http://radiantcms.org/mailing-list/search/)  
> Site: [http://lists.radiantcms.org/mailman/listinfo/radiant](http://lists.radiantcms.org/mailman/listinfo/radiant)

–  
Alexander H.  
[http://www2.truman.edu/~ah428](http://www2.truman.edu/~ah428)

---

<div class="post-metadata">

**Author:** ![p0pnfresh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7cd45c/32.png) [@p0pnfresh](https://www.ruby-forum.com/u/p0pnfresh)\
**Post date:** [October 17, 2006, 4:40am UTC](https://www.ruby-forum.com/t/utf-8-problem/72347/5 "2006-10-17T04:40:57Z")

</div>

On 17/10/2006, at 8:42 AM, Chris Lloyd wrote:

> I maybe totally wrong but I remember hearing somthing about full UTF-8  
> support coming into Rails 1.2.

Rails has kind-of supported utf-8 for a long time, there has just  
been some traps which i think they are trying to get rid of, like  
validations and other stuff (i _think_).

Jose, what version of mysql are you on? am I correct in thinking the  
only problem is when you look at the data with the mysql command-line  
client or export from mysqldump?

Bodhi

---

<div class="post-metadata">

**Author:** ![p0pnfresh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7cd45c/32.png) [@p0pnfresh](https://www.ruby-forum.com/u/p0pnfresh)\
**Post date:** [October 17, 2006, 1:44am UTC](https://www.ruby-forum.com/t/utf-8-problem/72347/6 "2006-10-17T01:44:27Z")

</div>

I maybe totally wrong but I remember hearing somthing about full UTF-8  
support coming into Rails 1.2.

Chris

---

<div class="post-metadata">

**Author:** ![p0pnfresh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7cd45c/32.png) [@p0pnfresh](https://www.ruby-forum.com/u/p0pnfresh)\
**Post date:** [October 17, 2006, 10:17am UTC](https://www.ruby-forum.com/t/utf-8-problem/72347/7 "2006-10-17T10:17:33Z")

</div>

On 10/16/06, Alexander H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Radiant does not control the charset when writing to the database.  
> That’s a good question though. I haven’t ever seen a Rails app  
> actually doing that type of stuff.

That’s an issue I reported to John a few months ago. You can put the  
“text/html; charset=utf-8” as content type for your own pages in the  
layout pane so that is working.

The only place where pages are by default in iso8859-1 is the admin  
interface. And there is no way  
except by patching the views/code to change that.

Having an option for that would be nice.

---

<div class="post-metadata">

**Author:** ![p0pnfresh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7cd45c/32.png) [@p0pnfresh](https://www.ruby-forum.com/u/p0pnfresh)\
**Post date:** [October 17, 2006, 5:18pm UTC](https://www.ruby-forum.com/t/utf-8-problem/72347/8 "2006-10-17T17:18:56Z")

</div>

Ollivier R. wrote:

> That’s an issue I reported to John a few months ago. You can put the  
> “text/html; charset=utf-8” as content type for your own pages in the  
> layout pane so that is working.

I believe this was fixed a while back? This is in the application.rhtml  
layout:

Does this not fix the problem?

–  
John

---

<div class="post-metadata">

**Author:** ![p0pnfresh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7cd45c/32.png) [@p0pnfresh](https://www.ruby-forum.com/u/p0pnfresh)\
**Post date:** [October 17, 2006, 10:10pm UTC](https://www.ruby-forum.com/t/utf-8-problem/72347/9 "2006-10-17T22:10:34Z")

</div>

Bodhi,

## mysql\> \s

mysql Ver 14.12 Distrib 5.0.22, for Win32 (ia32)

Connection id: 27  
Current database: aflmm\_dev  
Current user: jlopez@localhost  
SSL: Not in use  
Using delimiter: ;  
Server version: 5.0.22-community-nt  
Protocol version: 10  
Connection: localhost via TCP/IP  
Server characterset: utf8  
Db characterset: utf8  
Client characterset: utf8  
Conn. characterset: utf8  
TCP port: 3306  
Uptime: 7 hours 48 min 16 sec

Your’e right. The characters render properly in the website and in the  
Radiant admin backend. They only appear scrambled in the Mysql client  
and  
dump file.

* * *

---

<div class="post-metadata">

**Author:** ![p0pnfresh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7cd45c/32.png) [@p0pnfresh](https://www.ruby-forum.com/u/p0pnfresh)\
**Post date:** [October 17, 2006, 7:45pm UTC](https://www.ruby-forum.com/t/utf-8-problem/72347/10 "2006-10-17T19:45:55Z")

</div>

removed\_email\_address@domain.invalid wrote:

> The problem is, that when I write to the database using Radiant’s admin  
> back end, the accented characters (á,é,í,ó,ú) and the spanish letter ñ  
> appear scrambled in the mysql database. The chracters do render properly  
> in the browser via Radiant, although they don’t in the mysql database. And  
> if I export my mysql database the characters appear scrambled.

Just a wild guess: is the db connection in UTF8 mode? I.e. the first  
statement executed by mysql needs to be:

SET NAMES ‘utf8’;

You can force this command by placing a “encoding: utf8” line into the  
current environment’s section in database.yml.

## Zsombor

Company - [http://primalgrasp.com](http://primalgrasp.com)  
Thoughts - [http://deezsombor.blogspot.com](http://deezsombor.blogspot.com)

---

<div class="post-metadata">

**Author:** ![p0pnfresh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7cd45c/32.png) [@p0pnfresh](https://www.ruby-forum.com/u/p0pnfresh)\
**Post date:** [October 17, 2006, 10:22pm UTC](https://www.ruby-forum.com/t/utf-8-problem/72347/11 "2006-10-17T22:22:35Z")

</div>

Hi Ollivier,

I’ve set “utf-8” in the content-type tab of the Layout’s pane. It makes  
no  
difference. I’ve also checked application.rhtml and it does contain

between the head.

My Mysql is set to utf-8 as the default charset. Accented characters  
render properly in Radiant’s frontend (website) and backend (admin).  
It’s  
only when viewing the content directly from mysql or when dumping the  
content in an .sql file that characters appear scrambled.

Jose.

---

<div class="post-metadata">

**Author:** ![p0pnfresh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7cd45c/32.png) [@p0pnfresh](https://www.ruby-forum.com/u/p0pnfresh)\
**Post date:** [October 18, 2006, 10:27pm UTC](https://www.ruby-forum.com/t/utf-8-problem/72347/12 "2006-10-18T22:27:15Z")

</div>

Hi,

Thanks everyone who has kindly responded to my noobery. The problem was,  
that I was managing the Mysql database using the Mysql Gui (provided in  
the official Mysql page), and that program also has an option to set the  
character encoding.

Now eveything is set to UTF8 and chracters render properly everywhere.

Bodhi, I’m using Windows locally to experiment with charset UTF-8,  
because  
I’m developing the website for the Archive of the Luis  
Muñoz MarínFoundation in Puerto Rico, which inevitably needs support for spanish  
characters. The new website will reside on a Linux hosting, I just  
wanted  
to make sure I could start working locally and then export everything to  
a  
remote machine.

By the way, please check out my first Radiant website, developed for the  
Virtual Caribbean initiative of the University of Puerto Rico. It’s  
still  
running in development mode. But soon we’ll be finished and ready to  
deploy in production.

[http://cybrary.hpcf.upr.edu:3000](http://cybrary.hpcf.upr.edu:3000)

Nice mailing list people keep it up!

Jose.

---

<div class="post-metadata">

**Author:** ![p0pnfresh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/7cd45c/32.png) [@p0pnfresh](https://www.ruby-forum.com/u/p0pnfresh)\
**Post date:** [October 18, 2006, 3:45am UTC](https://www.ruby-forum.com/t/utf-8-problem/72347/13 "2006-10-18T03:45:13Z")

</div>

On 18/10/2006, at 5:21 AM, removed\_email\_address@domain.invalid wrote:

> My Mysql is set to utf-8 as the default charset. Accented characters  
> render properly in Radiant’s frontend (website) and backend  
> (admin). It’s  
> only when viewing the content directly from mysql or when dumping the  
> content in an .sql file that characters appear scrambled.

Does your terminal support utf-8? try hitting your website with curl  
and see what your output looks like. Ah, I just read your other  
email, seems like you are on windows? What programs are you using to  
look at the sql dump?

Bodhi
