Fix ruby encoding detection