# ActiveSupport::Multibyte question || Rails console question

**URL:** <https://www.ruby-forum.com/t/activesupport-multibyte-question-rails-console-question/71338>\
**Category:** Rails\
**Created:** [October 7, 2006, 7:19am UTC](https://www.ruby-forum.com/t/activesupport-multibyte-question-rails-console-question/71338 "2006-10-07T07:19:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AdriSSSSn\_De\_la\_Cru](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b487fb/32.png) [@AdriSSSSn\_De\_la\_Cru](https://www.ruby-forum.com/u/AdriSSSSn_De_la_Cru)\
**Post date:** [October 7, 2006, 7:19am UTC](https://www.ruby-forum.com/t/activesupport-multibyte-question-rails-console-question/71338/1 "2006-10-07T07:19:40Z")

</div>

Hello guys,

I just saw this video:  
[http://www.fngtps.com/2006/10/activesupport-multibyte](http://www.fngtps.com/2006/10/activesupport-multibyte)  
And was trying to reproduce the example in there. I got Edge Rails  
(rev5229).

So what I did was this (the comments are the output from the console):  
$KCODE = ‘u’ # =\> ‘u’  
c = ‘Café is a nice word’ # =\> “Caf\202 is a nice word”  
puts c.reverse # drow ecin a si éfaC

As you can see these results are quite different from what appears on  
the video. Furthermore if I type this:  
puts c.chars.reverse # drow ecin a si ôÇÜfaC

And what’s even worse, it even modified my string and now my c object  
is messed up, if I type this:  
c # I get this: CafôÇÜ is a nice word

It modified my string!  
Anyone has any ideas why this could be happening?

# About the rails console:

Oh, and I want to know, why I can’t use my Alt Gr key in the rails  
console, neither my numpad to input ASCII codes for chars that I need  
(because I can’t use the Alt Gr key).

For example, I can’t type “[” (a square bracket) in the console,  
because I need to push "Alt Gr + “[”, so I thought:  
“hmm I will use the ASCII code for that square bracket” (the code it’s  
91),  
and when I tried to use my numpad in combination with my ALT key,  
unexpected characters started to appear.

When numlock is activated, pressing ALT + Numpad1 I get the “a” char.  
When numlock is deactivated, pressing that key combo will render a “#”  
char.

Any ideas?

---

<div class="post-metadata">

**Author:** ![AdriSSSSn\_De\_la\_Cru](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b487fb/32.png) [@AdriSSSSn\_De\_la\_Cru](https://www.ruby-forum.com/u/AdriSSSSn_De_la_Cru)\
**Post date:** [October 7, 2006, 8:39am UTC](https://www.ruby-forum.com/t/activesupport-multibyte-question-rails-console-question/71338/2 "2006-10-07T08:39:44Z")

</div>

Woops, forgot to mention that I got a keyboard for the spanish  
language (you know, those with the “ñ” key, and others).

---

<div class="post-metadata">

**Author:** ![AdriSSSSn\_De\_la\_Cru](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b487fb/32.png) [@AdriSSSSn\_De\_la\_Cru](https://www.ruby-forum.com/u/AdriSSSSn_De_la_Cru)\
**Post date:** [October 7, 2006, 11:37am UTC](https://www.ruby-forum.com/t/activesupport-multibyte-question-rails-console-question/71338/3 "2006-10-07T11:37:54Z")

</div>

Hi,

Le 7 oct. 06, à 07:16, Adrián De la Cruz a écrit :

> 

Your console is not set to utf-8 ?

Jean-Christophe M.

---

<div class="post-metadata">

**Author:** ![AdriSSSSn\_De\_la\_Cru](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b487fb/32.png) [@AdriSSSSn\_De\_la\_Cru](https://www.ruby-forum.com/u/AdriSSSSn_De_la_Cru)\
**Post date:** [October 8, 2006, 5:21am UTC](https://www.ruby-forum.com/t/activesupport-multibyte-question-rails-console-question/71338/4 "2006-10-08T05:21:27Z")

</div>

Too bad, I’m in a windows box =(

Any tips to solve my problem? (besides switching to Linux!).

---

<div class="post-metadata">

**Author:** ![AdriSSSSn\_De\_la\_Cru](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/b487fb/32.png) [@AdriSSSSn\_De\_la\_Cru](https://www.ruby-forum.com/u/AdriSSSSn_De_la_Cru)\
**Post date:** [October 7, 2006, 7:08pm UTC](https://www.ruby-forum.com/t/activesupport-multibyte-question-rails-console-question/71338/5 "2006-10-07T19:08:27Z")

</div>

On 7-okt-2006, at 11:35, Jean-Christophe M. wrote:

> > So what I did was this (the comments are the output from the  
> > console):  
> > $KCODE = ‘u’ # =\> ‘u’  
> > c = ‘Café is a nice word’ # =\> “Caf\202 is a nice word”  
> > puts c.reverse # drow ecin a si éfaC  
> > Any ideas?
> 
> Your console is not set to utf-8 ?

I guess the question is right. What you need in this case is a UTF-8  
roundtrip, that is

## export LANG=en\_US.UTF-8

Julian ‘Julik’ Tarkhanov  
please send all personal mail to  
me at julik.nl
