From: Jim Hranicky Date: 2012-05-03T06:41:57+09:00 Subject: Re: Psych dumping in binary On 05/02/2012 05:10 PM, Jeremy Kemper wrote: > If you can, try US-ASCII encoding for 7-bit clean ASCII. Psych will > dump that as you expect. Well, I'd rather avoid this when reading and parsing syslog lines: ruby -Eus-ascii -e 'x = "foo"; x.force_encoding("US-ASCII"); puts x.encoding; x += "\xf0\xff"; x.force_encoding("US-ASCII"); puts x.match(/foo/); puts x' | m -e:1:in `match': invalid byte sequence in US-ASCII (ArgumentError) from -e:1:in `match' from -e:1:in `
' US-ASCII You never know what'll be in there, and I'd rather not have to run force_encoding on every processed line. If there's a better way to handle strings with naughty characters I'd be grateful for pointers. -- Jim Hranicky IT Security Engineer Office of Information Security and Compliance University of Florida