Ruby 1.9.1 generates "invalid multibyte char (US-ASCII)"

3,478 views
Skip to first unread message

Kristopher Murata

unread,
Aug 11, 2010, 11:04:38 PM8/11/10
to sina...@googlegroups.com
Hey all, I'm still dealing with this issue and since no one commented on github ( http://github.com/sinatra/sinatra/issues#issue/38 ) I'm beginning to think that it's only happening with me, can anyone reproduce this very same bug?

Piotr Szotkowski

unread,
Aug 12, 2010, 3:04:04 AM8/12/10
to sina...@googlegroups.com
Kristopher Murata:

> http://github.com/sinatra/sinatra/issues#issue/38

I think the whole point of Ruby encodings is that you specify them in
the file where the encoding is used; if I wrote in something else than
UTF-8, adding ‘# encoding: UTF-8’ to tilt.rb wouldn’t help me at all.

You should add the comment to the file which contains
the non-US-ASCII string or run Ruby with the -KU switch.

— Piotr Szotkowski
--
phrases that shouldn’t exist on the web:
read more after the jump
skip this ad
remember me on this computer
page 1 of #
[Faruk Ateş]

signature.asc

darkhelmetlive

unread,
Aug 12, 2010, 6:21:03 PM8/12/10
to sinatrarb
I had problems with encoding on ruby 1.9 with sinatra, but solved it
by specifying default_internal and default_external encoding

Encoding.default_external = 'utf-8'
Encoding.default_internal = 'utf-8'

- Daniel

On Aug 11, 9:04 pm, Kristopher Murata <krsmur...@gmail.com> wrote:
> Hey all, I'm still dealing with this issue and since no one commented on
> github (http://github.com/sinatra/sinatra/issues#issue/38) I'm beginning

Piotr Szotkowski

unread,
Aug 13, 2010, 1:16:43 AM8/13/10
to sina...@googlegroups.com
darkhelmetlive:

> I had problems with encoding on ruby 1.9 with sinatra, but solved
> it by specifying default_internal and default_external encoding

> Encoding.default_external = 'utf-8'
> Encoding.default_internal = 'utf-8'

Note that the above throws Ruby warnings:

chastell@devielle:~$ ruby -wve "Encoding.default_external = 'UTF-8'; Encoding.default_internal = 'UTF-8'"
ruby 1.9.1p378 (2010-01-10 revision 26273) [x86_64-linux]
-e:1: warning: setting Encoding.default_external
-e:1: warning: setting Encoding.default_internal
chastell@devielle:~$

— Piotr Szotkowski
--
Amateur fighter pilot ignores orders, listens to
the voices in his head and slaughters thousands.
[Star Wars ending explained]

signature.asc
Reply all
Reply to author
Forward
0 new messages