This, in perl: $str =~ tr/\0\200/\200\0/; Produces a different result then this: str.tr!("\0\200","\200\0") How do I do this in ruby?