# Html special chars

**URL:** <https://www.ruby-forum.com/t/html-special-chars/107264>\
**Category:** Rails\
**Created:** [June 19, 2007, 8:47pm UTC](https://www.ruby-forum.com/t/html-special-chars/107264 "2007-06-19T20:47:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![damianrr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a587f6/32.png) [@damianrr](https://www.ruby-forum.com/u/damianrr)\
**Post date:** [June 19, 2007, 8:47pm UTC](https://www.ruby-forum.com/t/html-special-chars/107264/1 "2007-06-19T20:47:24Z")

</div>

Hi, i have a database with data that contains special html chars … for  
example, i may have names like “damiÃ¡n” “guzmÃ¡n” and they get displayed  
like “dami?n” and “guzm?n” in the browser, i need a render function that  
allow me to convert those names to the html version (“damián” and  
“guzmán”) before display them … any ideas will be most welcome  
… thanks

---

<div class="post-metadata">

**Author:** ![damianrr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a587f6/32.png) [@damianrr](https://www.ruby-forum.com/u/damianrr)\
**Post date:** [June 29, 2007, 3:50am UTC](https://www.ruby-forum.com/t/html-special-chars/107264/2 "2007-06-29T03:50:16Z")

</div>

On Jun 25, 2007, at 9:22 , Damian Rr wrote:

> how can i convert the data in my database to utf8?

Depends on the database. For PostgreSQL you need to

- dump your database
- run the dump through iconv
- create a new database with the UTF8 encoding, and
- load your dumpfile into the new database.

Michael G.  
grzm seespotcode net

---

<div class="post-metadata">

**Author:** ![damianrr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a587f6/32.png) [@damianrr](https://www.ruby-forum.com/u/damianrr)\
**Post date:** [June 25, 2007, 4:22pm UTC](https://www.ruby-forum.com/t/html-special-chars/107264/3 "2007-06-25T16:22:08Z")

</div>

Bob S. wrote:

> On 6/19/07, Damian Rr [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Hi, i have a database with data that contains special html chars … for  
> > example, i may have names like “damiï¿½n” “guzmï¿½n” and they get displayed  
> > like “dami?n” and “guzm?n” in the browser, i need a render function that  
> > allow me to convert those names to the html version (“damián” and  
> > “guzmán”) before display them … any ideas will be most welcome  
> > … thanks
> 
> Why not just declare your output encoding to match the encoding of the  
> data in your database? Or better yet, convert the data in the database  
> to UTF-8, which all modern browsers support and which Rails sets as  
> default output encoding.
> 
> HTML entities are handy for use in literals in your source code, but  
> aren’t really appropriate for your data in this case.

how can i convert the data in my database to utf8?

---

<div class="post-metadata">

**Author:** ![damianrr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/a587f6/32.png) [@damianrr](https://www.ruby-forum.com/u/damianrr)\
**Post date:** [June 19, 2007, 9:03pm UTC](https://www.ruby-forum.com/t/html-special-chars/107264/4 "2007-06-19T21:03:38Z")

</div>

On 6/19/07, Damian Rr [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi, i have a database with data that contains special html chars … for  
> example, i may have names like “damián” “guzmán” and they get displayed  
> like “dami?n” and “guzm?n” in the browser, i need a render function that  
> allow me to convert those names to the html version (“damián” and  
> “guzmán”) before display them … any ideas will be most welcome  
> … thanks

Why not just declare your output encoding to match the encoding of the  
data in your database? Or better yet, convert the data in the database  
to UTF-8, which all modern browsers support and which Rails sets as  
default output encoding.

HTML entities are handy for use in literals in your source code, but  
aren’t really appropriate for your data in this case.
