# Textarea problem with accentued chars

**URL:** <https://www.ruby-forum.com/t/textarea-problem-with-accentued-chars/62139>\
**Category:** Rails\
**Created:** [January 17, 2006, 9:41pm UTC](https://www.ruby-forum.com/t/textarea-problem-with-accentued-chars/62139 "2006-01-17T21:41:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![oo00oo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8797f3/32.png) [@oo00oo](https://www.ruby-forum.com/u/oo00oo)\
**Post date:** [January 17, 2006, 9:41pm UTC](https://www.ruby-forum.com/t/textarea-problem-with-accentued-chars/62139/1 "2006-01-17T21:41:22Z")

</div>

Hello, I have a problem with accentued characters return from a textarea

I have 3 simple files to show example ( below ).

index.rhml : If I put “énial” inside the textarea, then submit to  
:action =\> post

post.rhml : wrote

énial

195

“\303\251nial”

//

params[:comment][:message] return =\> énial

params[:comment][:message][1] return =\> 195 ! ( 195 is not “é” ,  
[http://www.asciitable.com/](http://www.asciitable.com/) )

params[:comment][:message].inspect return =\> “\303\251nial”

and in ddb I store “Ã©nial”

Someone can help me please ?

//

## test\_controller.rb :

class TestController \< ActionController::Base

def index  
end

def post  
@var1 = params[:comment][:message]  
@var2 = params[:comment][:message][0]  
@var3 = params[:comment][:message].inspect

```
hash = { :name => params[:comment][:message] }
obj = Color.new( hash )
obj.save

```

end

end

## index.rhtml :

\<%= start\_form\_tag :action =\> ‘post’ %\>

Message  
 \<%= text\_area "comment" , "message" %\>

 \<%= submit\_tag "Post" %\> \<%= end\_form\_tag %\>
## post.rhtml :

\<%= @var1 %\>

\<%= @var2 %\>

\<%= @var3 %\>

---

<div class="post-metadata">

**Author:** ![oo00oo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8797f3/32.png) [@oo00oo](https://www.ruby-forum.com/u/oo00oo)\
**Post date:** [January 18, 2006, 2:00am UTC](https://www.ruby-forum.com/t/textarea-problem-with-accentued-chars/62139/2 "2006-01-18T02:00:44Z")

</div>

On 17 Jan '06, at 12:04 PM, oo00oo wrote:

> Hello, I have a problem with accentued characters return from a  
> textarea  
> index.rhml : If I put “Ã©nial” inside the textarea, then submit  
> to :action =\> post  
> post.rhml : wrote  
> Ã©nial  
> 195  
> “\303\251nial”

Looks like a classic encoding mismatch: the browser is returning  
UTF-8 and you’re expecting something different (probably WinLatin1,  
aka CP-1252). Make sure your HTML has a tag specifying the  
intended encoding.

> params[:comment][:message][1] return =\> 195 ! ( 195 is not  
> “Ã©” , [http://www.asciitable.com/](http://www.asciitable.com/) )

195 may not be “Ã©” in the particular encoding you’re used to, but  
that doesn’t mean it isn’t in some other encoding. That  
“[asciitable.com](http://asciitable.com)” site is rather naÃ¯ve … “ascii” refers only to the  
low 7 bits (0…127), and there is absolutely no agreed-on “extended  
ascii” standard. There are dozens and dozens of different encodings  
for (128…255), and there are encodings that encode some characters  
using two or more bytes. UTF-8 is slowly becoming the lingua franca,  
though.

This brings up the question in my mind of how to deal with UTF-8 in  
Ruby. Last checked, there was no native support for different  
character encodings or Unicode text. Has that been improved since  
1.6? Or are there optional libraries we can use to work with Unicode?

–Jens

---

<div class="post-metadata">

**Author:** ![oo00oo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8797f3/32.png) [@oo00oo](https://www.ruby-forum.com/u/oo00oo)\
**Post date:** [January 18, 2006, 12:21pm UTC](https://www.ruby-forum.com/t/textarea-problem-with-accentued-chars/62139/3 "2006-01-18T12:21:24Z")

</div>

Jens A. wrote:

> This brings up the question in my mind of how to deal with UTF-8 in  
> Ruby. Last checked, there was no native support for different character  
> encodings or Unicode text. Has that been improved since 1.6? Or are  
> there optional libraries we can use to work with Unicode?

The canned response is KCODE=‘u’; require ‘jcode’; but that’s got a  
whole bunch of holes in it. By strange coincidence, though, \_why posted  
this a couple of days ago:

[http://redhanded.hobix.com/inspect/unicodeLibForRuby18.html](http://redhanded.hobix.com/inspect/unicodeLibForRuby18.html)

–  
Alex

---

<div class="post-metadata">

**Author:** ![oo00oo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8797f3/32.png) [@oo00oo](https://www.ruby-forum.com/u/oo00oo)\
**Post date:** [January 18, 2006, 12:33pm UTC](https://www.ruby-forum.com/t/textarea-problem-with-accentued-chars/62139/4 "2006-01-18T12:33:27Z")

</div>

2006/1/18, Alex Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> [http://redhanded.hobix.com/inspect/unicodeLibForRuby18.html](http://redhanded.hobix.com/inspect/unicodeLibForRuby18.html)

Optional library: [http://rubyforge.org/projects/icu4r](http://rubyforge.org/projects/icu4r) - still in  
development 🙂

---

<div class="post-metadata">

**Author:** ![oo00oo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/8797f3/32.png) [@oo00oo](https://www.ruby-forum.com/u/oo00oo)\
**Post date:** [January 29, 2006, 1:19pm UTC](https://www.ruby-forum.com/t/textarea-problem-with-accentued-chars/62139/5 "2006-01-29T13:19:44Z")

</div>

I have the same problem now, did u “win” it?

Thanks,  
Mikhail
