Previously, it was done by:

     URLEncoder.encode(s, charset.name());