# Strange characters in rails

**URL:** <https://www.ruby-forum.com/t/strange-characters-in-rails/154391>\
**Category:** Rails\
**Created:** [November 28, 2008, 3:59pm UTC](https://www.ruby-forum.com/t/strange-characters-in-rails/154391 "2008-11-28T15:59:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![giantiago](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/7bcc69/32.png) [@giantiago](https://www.ruby-forum.com/u/giantiago)\
**Post date:** [November 28, 2008, 3:59pm UTC](https://www.ruby-forum.com/t/strange-characters-in-rails/154391/1 "2008-11-28T15:59:46Z")

</div>

I wrote some time ago a post about how to deal with some strange  
characters (Brazilan Portuguese in my case) that appears mysteriously  
sometimes in our dear Rails apps.

Note that is is a different problem that the Multibyte solves.

For Latin languages, this can be quite annoying and most times very  
difficult to deal with. I read a article, I will try to find it, but it  
basically teach us to stop doing anything related to programing unless  
you do understand what character encoding mean. Can’t find it but for  
the purpose of this post, it is well said.

But it happens that there is _one_ way of doing this and the _right_ way  
of doig thing.

So, my first post was one way.

And this is the right way :

require ‘iconv’  
ic\_translit1 = Iconv.new( ‘UTF-8//IGNORE//TRANSLIT’,‘WINDOWS-1252’)  
@file=ic\_translit1.iconv(@file)

You should transform the text between the various encodings by correctly  
initializing the Iconv object.

Consider what the input text encoding and the output (usually UFT-8 in  
Rails) you have to display.

Hope this helps.
