Class JSURLEncoder

java.lang.Object
com.oracle.truffle.js.runtime.builtins.JSURLEncoder

public final class JSURLEncoder extends Object
Utility class for encodeURI and encodeURIComponent.

When encoding a String, the following rules apply:

  • The alphanumeric characters "a" through "z", "A" through "Z" and "0" through "9" remain the same.
  • The special characters in the mark set in the case of encodeURIComponent, and additionally those in the reserved set plus "#invalid input: '&quot' in the case of encodeURI; remain the same.
  • The space character " " is converted into a plus sign " +".
  • All other characters are unsafe and are first converted into one or more bytes using some encoding scheme. Then each byte is represented by the 3-character string " %xy", where xy is the two-digit hexadecimal representation of the byte. The default encoding scheme is UTF-8.
  • Constructor Details

    • JSURLEncoder

      public JSURLEncoder(boolean isSpecial)
    • JSURLEncoder

      public JSURLEncoder(boolean isSpecial, Charset charset)
  • Method Details

    • encode

      public com.oracle.truffle.api.strings.TruffleString encode(com.oracle.truffle.api.strings.TruffleString s)
    • charForDigit

      public static char charForDigit(int digit, int radix)
      Like Character.forDigit(int, int), but returns uppercase letters.