# Encoding problems (i think utf-8 problems)

**URL:** <https://www.ruby-forum.com/t/encoding-problems-i-think-utf-8-problems/88976>\
**Category:** Rails\
**Created:** [March 15, 2007, 11:51pm UTC](https://www.ruby-forum.com/t/encoding-problems-i-think-utf-8-problems/88976 "2007-03-15T23:51:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dweinand](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f17d59/32.png) [@dweinand](https://www.ruby-forum.com/u/dweinand)\
**Post date:** [March 15, 2007, 11:51pm UTC](https://www.ruby-forum.com/t/encoding-problems-i-think-utf-8-problems/88976/1 "2007-03-15T23:51:54Z")

</div>

i have problems with umlauts (ï¿½ï¿½ï¿½) sent from an observer to my  
controller.  
i dont exactely know what my controller receives. using rails 1.1.6 on  
Win XP

the text field is observed with this Observer:

\<%= observe\_field ‘suche’, :frequency =\> 2,  
:update =\> ‘angebote’,  
:before =\> “Element.show(‘snake\_spinner’)”,  
:complete =\> “Element.hide(‘snake\_spinner’)”,  
:url =\> {:action =\> ‘suche\_angebote’},  
:with =\> " ‘query=’+ encodeURIComponent($(‘suche’).value)"  
%\>

everything works fine. but if i enter umlauts into my field ‘suche’, i  
get strange values passed to my controller.  
so, if i type in: ï¿½ in my controller i’ll receive the following as  
param: “query”=\>“\303\266”

is this du the lack of utf-8 support in ruby/rails or what is  
happening here? or a js problem?  
saving and displaying umlauts in/from the database works without any  
problems.

in application.rhtml:

headers from the observer POST:  
Host localhost:3000  
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.2)  
Gecko/20070219 Firefox/2.0.0.2  
Accept text/javascript, text/html, application/xml, text/xml, _/_  
Accept-Language de-de,de;q=0.8,en-us;q=0.5,en;q=0.3  
Accept-Encoding gzip,deflate  
Accept-Charset ISO-8859-1,utf-8;q=0.7,\*;q=0.7  
Keep-Alive 300  
Connection keep-alive  
X-Requested-With XMLHttpRequest  
X-Prototype-Version 1.5.0  
Content-Type application/x-www-form-urlencoded; charset=UTF-8  
Referer [http://localhost:3000/dokument/list](http://localhost:3000/dokument/list)  
Content-Length 9  
Cookie \_session\_id=14fde434003ce9fa32f57af64c8a6af2  
Pragma no-cache  
Cache-Control no-cache

---

<div class="post-metadata">

**Author:** ![dweinand](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f17d59/32.png) [@dweinand](https://www.ruby-forum.com/u/dweinand)\
**Post date:** [March 16, 2007, 8:22am UTC](https://www.ruby-forum.com/t/encoding-problems-i-think-utf-8-problems/88976/2 "2007-03-16T08:22:32Z")

</div>

no one?

---

<div class="post-metadata">

**Author:** ![dweinand](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f17d59/32.png) [@dweinand](https://www.ruby-forum.com/u/dweinand)\
**Post date:** [March 17, 2007, 8:02am UTC](https://www.ruby-forum.com/t/encoding-problems-i-think-utf-8-problems/88976/3 "2007-03-17T08:02:34Z")

</div>

On Mar 16, 6:50 am, “dweinand” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> so, if i type in: ? in my controller i’ll receive the following as  
> param: “query”=\>“\303\266”

> > puts “\303\266”  
> > ö

Looks right to me (assuming that the character you pasted in your post  
(?) is the umlaut-o)… if you use String#inspect (which is likely  
what Rails’ log output uses) on a string, non-ascii chars will be  
shown as octal escapes. In this case, “\303\266” happens to be the  
utf-8 representation of codepoint 0xf6, “LATIN SMALL LETTER O WITH  
DIAERESIS”.

> saving and displaying umlauts in/from the database works without  
> any problems.

So where’s the issue?
