# Encoding problems

**URL:** <https://www.ruby-forum.com/t/encoding-problems/181959>\
**Category:** Ruby\
**Created:** [January 20, 2010, 8:46pm UTC](https://www.ruby-forum.com/t/encoding-problems/181959 "2010-01-20T20:46:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f07891/32.png) [@nax](https://www.ruby-forum.com/u/nax)\
**Post date:** [January 20, 2010, 8:46pm UTC](https://www.ruby-forum.com/t/encoding-problems/181959/1 "2010-01-20T20:46:40Z")

</div>

Hi all.

I have a database (sqlite) with Ansi - LatÃ­n I codepage. With a Select  
statement in Ruby, the data returned are in UTF-8. E. g.:

Database: ocupaciÃ³n  
Ruby : ocupaci\xC3\xB3n

How can I display the correct data (i. e., ocupaciÃ³n)?

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![nax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f07891/32.png) [@nax](https://www.ruby-forum.com/u/nax)\
**Post date:** [January 20, 2010, 9:15pm UTC](https://www.ruby-forum.com/t/encoding-problems/181959/2 "2010-01-20T21:15:54Z")

</div>

On Jan 20, 4:46 pm, Noé Alejandro [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi all.
> 
> I have a database (sqlite) with Ansi - Latín I codepage. With a Select  
> statement in Ruby, the data returned are in UTF-8. E. g.:
> 
> Database: ocupación  
> Ruby : ocupaci\xC3\xB3n
> 
> How can I display the correct data (i. e., ocupación)?

All that depends on the console encoding you’re trying to output that  
information to.

If is terminal on Linux/OSX, most likely is going to work as console  
is UTF8

On Windows, you need the console be set the codepage to 1252, which is  
not default (use chcp)

---

<div class="post-metadata">

**Author:** ![nax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f07891/32.png) [@nax](https://www.ruby-forum.com/u/nax)\
**Post date:** [January 20, 2010, 9:30pm UTC](https://www.ruby-forum.com/t/encoding-problems/181959/3 "2010-01-20T21:30:54Z")

</div>

Luis L. wrote:

> On Jan 20, 4:46ï¿½pm, Noï¿½ Alejandro [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Hi all.
> > 
> > I have a database (sqlite) with Ansi - Latï¿½n I codepage. With a Select  
> > statement in Ruby, the data returned are in UTF-8. E. g.:
> > 
> > Database: ocupaciï¿½n  
> > Ruby ï¿½ ï¿½: ocupaci\xC3\xB3n
> > 
> > How can I display the correct data (i. e., ocupaciï¿½n)?
> 
> All that depends on the console encoding you’re trying to output that  
> information to.
> 
> If is terminal on Linux/OSX, most likely is going to work as console  
> is UTF8
> 
> On Windows, you need the console be set the codepage to 1252, which is  
> not default (use chcp)

Hi.

Im using JetBrains RubyMine IDE (windows). I put in the first line

# encoding: WINDOWS-1252

Is that enough? I run it but the problem is the same =(
