updated encoding processing in ruby mode