From: "R.. Kumar" Date: 2010-06-16T13:20:16+09:00 Subject: Re: gsub: invalid byte sequence in US-ASCII Brian Candler wrote: > R.. Kumar wrote: >> If i replace ruby with perl -pe 's|....|g' that works fine. > > Replacing ruby 1.9.x with ruby 1.8.x is just as effective, and I would > recommend this for maintaining your sanity. > > I can only guess that the external encoding picked up from your > platform's environment is US-ASCII (are you using cygwin by any chance?) > > You probably need to set the external encoding to UTF-8 or BINARY for > your regexp not to crash. Try adding -Ku or -Kn to your ruby command > line. > > If you want to attempt to understand String encoding in ruby 1.9, then > good luck to you. I tried, documented what I found here: > http://github.com/candlerb/string19/blob/master/string19.rb > and gave up after about 200 rules. There is no official documentation. 1. I have moved to 1.9 long back. Don't want to move back. 2. I am on OSX. I think I had _probably_ (?) solved this issue on my previous laptop (PPC) -- now I;ve migrated my user to a new machine (Snow Leopard). All my settings, should have moved. (I say this since I had commented out the perl line). LC_ALL=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 LANG=C 3. Thanks for the link, i will read it. But NO, i have already read up enough a few months back, and do not have the energy to do it again :-(. Thanks for the tip on -Ku / -Kn -- Posted via http://www.ruby-forum.com/.