From: Brian Candler Date: 2010-06-16T00:56:21+09:00 Subject: Re: gsub: invalid byte sequence in US-ASCII 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. -- Posted via http://www.ruby-forum.com/.