thanks hector,

i think you are right about the console. i tried the non-compat change
to case statements in ruby 1.9 with colons and console seemed fine
with that. so i guess somehow even though i change script/console to
#!/usr/local/ruby1.9/bin/ruby or even comment out the sherbang and
rename it script/console.rb and run it with my /usr/local ruby, i
still get 1.8. iguess

is there a way to set the ruby that console runs. this is one of those
things that i think it pretty convoluted in rails. we should just have
an external config file and set these things. all the calculated paths
and other "convention" stuff works most of the time, but sometimes it
just creates confusion. imho

regardless, any ideas about how to set the ruby version for console?
...gg

On Apr 12, 11:49 am, Hector Gomez <[email protected]> wrote:
> 1) 1.9 is the wild wild west unfortunately, even more in all this
> encoding
> mess so as a developer right now is your responsability to transcode
> any
> external data to UTF-8(or you encoding of choice).
> I have sent a GSOC proposal to resolve this problems and let rails
> handle this problems for you and well "just work".
>
> 2)  You can use the String#encode method supplied in ruby 1.9
> That does conversion between the supported encodings in ruby.
> It has a parameter to ignore or to replace invalid character with
> a placeholder value
>
> # encoding: utf-8
> pi = "pi = π "
> puts pi.encode("iso-8859-1", undef: :replace, replace: "??")
> returns    pi = ??
>
> 4) What you really want is to set the internal_encoding.
> If you have set the internal_encoding of your program
> every IO is transcode from its external_encoding to your
> internal_encoding in a transparent way.
> I recommend you read this blog:
>
> http://blog.grayproductions.net/articles/ruby_19s_three_default_encod...
>
> Rails doesn't remove the Encoding class is available in the console.
> I think your console for some reason is using ruby 1.8.
>
> On Apr 12, 2:41 am, buddycat <[email protected]> wrote:
>
> > hi all,
>
> > platform: debian lenny, ruby1.91.p0, passenger/apache-multithread,
> > rails2.3 in vendor/postres and sql server via odbc. all current gems.
>
> > i have legacy asp content on win2k servers that i wrap in rails
> > controllers. this all worked great with ruby1.8, but now that we are
> > dealing with encoded strings in ruby1.9, i am having page crashes
> > randomly as users have cut and pasted high ascii code characters (e.g.
> > ascii 150 - a fancy dash) that are ms only and non-standard.
>
> > normally, i just wouldn't have cared or even worried about it that
> > much; however, in testing this a bit further after a few mysterious
> > rails page crashes, i did more experimenting. i found that if i put
> > the following in my asp page, it will cause the rails page to fail
> > with "invalid byte sequence in utf-8"  ror/vendor/rails/activesupport/
> > lib/active_support/core_ext/blank.rb: 50
>
> > the offending asp code is:
>
> > <%= chr(150) %>
> > this is my own doing to reproduce the issue, but there are many non-
> > standard windows characters that are not utf-8 compliant that probably
> > riddle my sql server database because users like to cut and paste
> > content from word and other places.
>
> > it turns out that because the content that i bring in via ruby
> > net::http has non-utf8 characters, the encoding is set to ascii8bit
> > and when i do force_encoding(utf-8), valid_encoding is false and the
> > page just fails. html::sanitize isn't an option as i don't want to
> > strip the tags. the content is from internal trusted servers that i
> > control. i just need to sanizite, i guess, the bad characters.
>
> > my thoughts/questions:
> > 1) seems like rails should be less brittle about managing encoding
> > such that blank? doesn't just fail when the valid_encoding is false.
> > or you shouldn't be able to create a string if the encoding is bad. or
> > it should make best efforts to transliterate the bad characters.
> > something.
>
> > 2) is iconv my best option. seems kind of nuts that i have to reencode
> > the entire html page for one character. this does work using the
> > translit//ignore options i get my pages, but i wonder at the
> > overhead.
>
> > 3) as usual, trying to make my ms iis5 servers do anything useful is a
> > non-starter. sure it says it can generate utf-8, but trying it the
> > (typically confused and poorly documented) 25 different ways to make
> > it do so, results in nothing but more wasted time. so i need a good
> > rails solution that "just works."
>
> > 4) it occurs to me that it could also be that ruby is setting the
> > default to acsii for net::http regardless of how iis is sending it.
> > how do i check/set the encoding.default_external in rails. why does
> > rails remove the Encoding class. it isn't there in console, but is in
> > irb. i dislike rails remvoing native ruby classes.
>
> > please. i am so close to having ruby1.9/rails2.3 working, but this
> > encoding stuff is really a hassle.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to