# I18n.t and UTF-8 black diamond?

**URL:** <https://www.ruby-forum.com/t/i18n-t-and-utf-8-black-diamond/194632>\
**Category:** Rails\
**Created:** [September 8, 2010, 8:06am UTC](https://www.ruby-forum.com/t/i18n-t-and-utf-8-black-diamond/194632 "2010-09-08T08:06:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrkohrea](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4491bb/32.png) [@mrkohrea](https://www.ruby-forum.com/u/mrkohrea)\
**Post date:** [September 8, 2010, 8:06am UTC](https://www.ruby-forum.com/t/i18n-t-and-utf-8-black-diamond/194632/1 "2010-09-08T08:06:16Z")

</div>

I am using Rails 3.0.0.rc, Nginx 0.7.67, and Passenger 2.2.15. I am  
using I18n.t on string literals defined for various locales, for  
example: I18n.t(:organization), where the :es locale defines  
organization: “organización”.

I have verified the following:

- is set on HTML5 doctypes
- 

is set on HTML4 doctypes

- my text editor is set to encode files as UTF-8
- I am not pulling the strings from the database, so the database is  
not an issue.
- My browser is set to UTF-8 and auto-detect Universal.

And I still see the dreaded black diamond “?” for extended chars.

If I substitute HTML entities for the offending chars, e.g.  
organization: “organización” and call html\_safe on the result,  
I18n.t(:organization).html\_safe, the characters display correctly in  
the browser, , but it seems like that should not be required, and  
tedious to code.

What obvious thing am I missing here? Any help appreciated.

Thanks,

Michael

---

<div class="post-metadata">

**Author:** ![mrkohrea](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4491bb/32.png) [@mrkohrea](https://www.ruby-forum.com/u/mrkohrea)\
**Post date:** [September 8, 2010, 9:07am UTC](https://www.ruby-forum.com/t/i18n-t-and-utf-8-black-diamond/194632/2 "2010-09-08T09:07:44Z")

</div>

On Sep 8, 7:05 am, Michael K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> - my text editor is set to encode files as UTF-8  
> tedious to code.
> 
> What obvious thing am I missing here? Any help appreciated.

Have you checked what bytes are being sent over the wire by the  
server ?

Fred

---

<div class="post-metadata">

**Author:** ![mrkohrea](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4491bb/32.png) [@mrkohrea](https://www.ruby-forum.com/u/mrkohrea)\
**Post date:** [September 8, 2010, 2:49pm UTC](https://www.ruby-forum.com/t/i18n-t-and-utf-8-black-diamond/194632/3 "2010-09-08T14:49:33Z")

</div>

Michael K. wrote:

> I am using Rails 3.0.0.rc, Nginx 0.7.67, and Passenger 2.2.15. I am  
> using I18n.t on string literals defined for various locales, for  
> example: I18n.t(:organization), where the :es locale defines  
> organization: “organizaciï¿½n”.
> 
> I have verified the following:
> 
> - is set on HTML5 doctypes
> - 
> 
> is set on HTML4 doctypes
> 
> - my text editor is set to encode files as UTF-8
> - I am not pulling the strings from the database, so the database is  
> not an issue.
> - My browser is set to UTF-8 and auto-detect Universal.
> 
> And I still see the dreaded black diamond “?” for extended chars.

Those facts cannot all be true. If you are seeing the diamond, then  
your browser is trying to display the content as UTF-8 but being fed  
something else – most likely ISO 8859-1. Make sure the file containing  
the string in question is properly encoded – run it through iconv if  
necessary.

Best,  
–Â  
Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

Sent from my iPhone

---

<div class="post-metadata">

**Author:** ![mrkohrea](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/4491bb/32.png) [@mrkohrea](https://www.ruby-forum.com/u/mrkohrea)\
**Post date:** [September 8, 2010, 7:57pm UTC](https://www.ruby-forum.com/t/i18n-t-and-utf-8-black-diamond/194632/4 "2010-09-08T19:57:04Z")

</div>

Thanks for the replies. Marnen, you were correct, and the original  
file was in the wrong encoding.

-Michael
