# UTF-8 out of Hpricot

**URL:** <https://www.ruby-forum.com/t/utf-8-out-of-hpricot/151621>\
**Category:** Ruby\
**Created:** [October 23, 2008, 3:37pm UTC](https://www.ruby-forum.com/t/utf-8-out-of-hpricot/151621 "2008-10-23T15:37:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Diogo\_do\_Nascimento](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@Diogo\_do\_Nascimento](https://www.ruby-forum.com/u/Diogo_do_Nascimento)\
**Post date:** [October 23, 2008, 3:37pm UTC](https://www.ruby-forum.com/t/utf-8-out-of-hpricot/151621/1 "2008-10-23T15:37:47Z")

</div>

Hey,  
I’m trying to get some text out of an Hpricot Element but it’s not  
giving me the correct encoding. The text displays alright when I  
inspect the element.  
I’ve already set $KCODE to ‘U’  
Thks.

---

<div class="post-metadata">

**Author:** ![Diogo\_do\_Nascimento](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ee7513/32.png) [@Diogo\_do\_Nascimento](https://www.ruby-forum.com/u/Diogo_do_Nascimento)\
**Post date:** [October 27, 2008, 4:51pm UTC](https://www.ruby-forum.com/t/utf-8-out-of-hpricot/151621/2 "2008-10-27T16:51:24Z")

</div>

Diogo do Nascimento wrote:

> Hey,  
> I’m trying to get some text out of an Hpricot Element but it’s not  
> giving me the correct encoding. The text displays alright when I  
> inspect the element.  
> I’ve already set $KCODE to ‘U’  
> Thks.

that works for me

```
f = open(http://google.de/)
f.rewind
doc = Hpricot(Iconv.conv('utf-8', f.charset, 

```

f.readlines.join("\n")))
