Class EncodingUtil

java.lang.Object
org.apache.commons.httpclient.util.EncodingUtil

@Deprecated public class EncodingUtil extends Object
Deprecated.
Jakarta Commons HttpClient 3.x is deprecated in the Jenkins project. It is not recommended to use it in any new code. Instead, use HTTP client API plugins as a dependency in your code. E.g. Apache HttpComponents Client API 4.x Plugin or Async HTTP Client Plugin.
The home for utility methods that handle various encoding tasks.
Since:
2.0 final
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    formUrlEncode(NameValuePair[] pairs, String charset)
    Deprecated.
    Form-urlencoding routine.
    static byte[]
    Deprecated.
    Converts the specified string to byte array of ASCII characters.
    static String
    getAsciiString(byte[] data)
    Deprecated.
    Converts the byte array of ASCII characters to a string.
    static String
    getAsciiString(byte[] data, int offset, int length)
    Deprecated.
    Converts the byte array of ASCII characters to a string.
    static byte[]
    getBytes(String data, String charset)
    Deprecated.
    Converts the specified string to a byte array.
    static String
    getString(byte[] data, int offset, int length, String charset)
    Deprecated.
    Converts the byte array of HTTP content characters to a string.
    static String
    getString(byte[] data, String charset)
    Deprecated.
    Converts the byte array of HTTP content characters to a string.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • formUrlEncode

      public static String formUrlEncode(NameValuePair[] pairs, String charset)
      Deprecated.
      Form-urlencoding routine. The default encoding for all forms is `application/x-www-form-urlencoded'. A form data set is represented in this media type as follows: The form field names and values are escaped: space characters are replaced by `+', and then reserved characters are escaped as per [URL]; that is, non-alphanumeric characters are replaced by `%HH', a percent sign and two hexadecimal digits representing the ASCII code of the character. Line breaks, as in multi-line text field values, are represented as CR LF pairs, i.e. `%0D%0A'.

      if the given charset is not supported, ISO-8859-1 is used instead.

      Parameters:
      pairs - the values to be encoded
      charset - the character set of pairs to be encoded
      Returns:
      the urlencoded pairs
      Since:
      2.0 final
    • getString

      public static String getString(byte[] data, int offset, int length, String charset)
      Deprecated.
      Converts the byte array of HTTP content characters to a string. If the specified charset is not supported, default system encoding is used.
      Parameters:
      data - the byte array to be encoded
      offset - the index of the first byte to encode
      length - the number of bytes to encode
      charset - the desired character encoding
      Returns:
      The result of the conversion.
      Since:
      3.0
    • getString

      public static String getString(byte[] data, String charset)
      Deprecated.
      Converts the byte array of HTTP content characters to a string. If the specified charset is not supported, default system encoding is used.
      Parameters:
      data - the byte array to be encoded
      charset - the desired character encoding
      Returns:
      The result of the conversion.
      Since:
      3.0
    • getBytes

      public static byte[] getBytes(String data, String charset)
      Deprecated.
      Converts the specified string to a byte array. If the charset is not supported the default system charset is used.
      Parameters:
      data - the string to be encoded
      charset - the desired character encoding
      Returns:
      The resulting byte array.
      Since:
      3.0
    • getAsciiBytes

      public static byte[] getAsciiBytes(String data)
      Deprecated.
      Converts the specified string to byte array of ASCII characters.
      Parameters:
      data - the string to be encoded
      Returns:
      The string as a byte array.
      Since:
      3.0
    • getAsciiString

      public static String getAsciiString(byte[] data, int offset, int length)
      Deprecated.
      Converts the byte array of ASCII characters to a string. This method is to be used when decoding content of HTTP elements (such as response headers)
      Parameters:
      data - the byte array to be encoded
      offset - the index of the first byte to encode
      length - the number of bytes to encode
      Returns:
      The string representation of the byte array
      Since:
      3.0
    • getAsciiString

      public static String getAsciiString(byte[] data)
      Deprecated.
      Converts the byte array of ASCII characters to a string. This method is to be used when decoding content of HTTP elements (such as response headers)
      Parameters:
      data - the byte array to be encoded
      Returns:
      The string representation of the byte array
      Since:
      3.0