how do i make rails not use utf8

1 view
Skip to first unread message

john

unread,
Sep 24, 2010, 4:21:07 AM9/24/10
to Ruby on Rails: Talk
I want ror to not use utf8. I have tried setting $KCODE to 'n'.
Activercord still tries to convert my special characters to utf.

The character 'ê' comes as "\303\252'. I want it to show the ê WITHOUT
using utf8. I have NO reason to use utf8. I do not know if this is a
rails or ruby issue. Can someone please help?

Ruby: 1.8.7
Rails: 2.3.8
Database: Firebird 2.1.3

Frederick Cheung

unread,
Sep 24, 2010, 6:30:07 AM9/24/10
to Ruby on Rails: Talk


On Sep 24, 9:21 am, john <j...@consys.co.za> wrote:
> I want ror to not use utf8. I have tried setting $KCODE to 'n'.
> Activercord still tries to convert my special characters to utf.
>
> The character 'ê' comes as "\303\252'. I want it to show the ê WITHOUT
> using utf8. I have NO reason to use utf8. I do not know if this is a
> rails or ruby issue. Can someone please help?

I'd strongly recommend you reconsider that position - you've got to
use some encoding to encode your text, what encoding do you want to
use that is 'better' than utf-8 ?

There are multiple pieces to the problem:

- response to the user's browser need to state the correct character
set (ActionController::Base.default_charset controls the default
character set user)
- your database should be set to use correct collation etc (eg a utf8
string is not sorted in the same way as a latin1 string, some
sequences of bytes are not valid utf8 etc)
- your data needs to actually be in that encoding: if you have
existing content you will have to convert it all to this new encoding
(and depending on your content there might not be a single encoding
that covers all of them).
- browser shenanigans

To my knowledge, active record itself doesn't do any conversion
(beyond in some cases telling the adapter library what character set
it expects) - you're probably seeing the browser encode what you type
as utf-8

Fred
Reply all
Reply to author
Forward
0 new messages