Use encode helper

https://github.com/rubyspec/rubyspec/commit/c668b143c449df11266797c1249c90cd4d965404#commitcomment-2818462