# Bug in encoding: utf8?

**URL:** <https://www.ruby-forum.com/t/bug-in-encoding-utf8/87062>\
**Category:** Rails\
**Created:** [February 27, 2007, 9:49pm UTC](https://www.ruby-forum.com/t/bug-in-encoding-utf8/87062 "2007-02-27T21:49:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e8c25b/32.png) [@Joram](https://www.ruby-forum.com/u/Joram)\
**Post date:** [February 27, 2007, 9:49pm UTC](https://www.ruby-forum.com/t/bug-in-encoding-utf8/87062/1 "2007-02-27T21:49:35Z")

</div>

Hello,

Today, I had to show some of the work done to my supervisor.  
When I wanted to show that all the tests ran correctly iI just ‘raked’  
as usual. However, every single unit test had an error. Off course  
that only happens when you have to do a demonstration.

The problem however, was quickly discovered.  
I added yesterday ‘encoding: utf8’ to database.yml (MySql 5.0.22) to  
correctly show some non-ascii characters, which works perfectly. After  
removing this rule, all tests ran correctly.

The application itself had no problems with the new rule.  
Is this a known bug? If so, is there a fix.  
I’m running Rails 1.2.

---

<div class="post-metadata">

**Author:** ![Joram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e8c25b/32.png) [@Joram](https://www.ruby-forum.com/u/Joram)\
**Post date:** [March 5, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/bug-in-encoding-utf8/87062/2 "2007-03-05T17:06:03Z")

</div>

On 2/27/07, Joram [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The problem however, was quickly discovered.  
> I added yesterday ‘encoding: utf8’ to database.yml (MySql 5.0.22) to  
> correctly show some non-ascii characters, which works perfectly. After  
> removing this rule, all tests ran correctly.
> 
> The application itself had no problems with the new rule.  
> Is this a known bug? If so, is there a fix.  
> I’m running Rails 1.2.

Are all of your test scripts using UTF-8 string literals?

Rails 1.2 has a Chars class for UTF-8 text. Unlike kCODE which  
modifies the Ruby string class methods to process UTF characters  
correctly.
