UEncoder (Apache Tomcat 9.0.117 API Documentation)
Description: declaration: package: org.apache.tomcat.util.buf, class: UEncoder

# Class UEncoder

java.lang.Object
org.apache.tomcat.util.buf.UEncoder

public final class UEncoder extends Object
Efficient implementation of a UTF-8 encoder. This class is not thread safe - you need one encoder per thread. The encoder will save and recycle the internal objects, avoiding garbage. You can add extra characters that you want preserved, for example while encoding a URL you can add "/".

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static enum`
  `UEncoder.SafeCharsSet`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `UEncoder(UEncoder.SafeCharsSet safeCharsSet)`
  Create a UEncoder with an unmodifiable safe character set.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `CharChunk`
  `encodeURL(String s, int start, int end)`
  URL Encode string, using a specified encoding.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### UEncoder

    public UEncoder(UEncoder.SafeCharsSet safeCharsSet)
    Create a UEncoder with an unmodifiable safe character set.
    Parameters:
      `safeCharsSet` - safe characters for this encoder

- ## Method Details

  - ### encodeURL

    public CharChunk encodeURL(String s, int start, int end) throws IOException
    URL Encode string, using a specified encoding.
    Parameters:
      `s` - string to be encoded
      `start` - the beginning index, inclusive
      `end` - the ending index, exclusive
    Returns:
      A new CharChunk contained the URL encoded string
    Throws:
      `IOException` - If an I/O error occurs