Package proguard.util

Class StringUtil

java.lang.Object
proguard.util.StringUtil

public class StringUtil extends Object
This class contains utility methods for strings.
  • Constructor Details

    • StringUtil

      public StringUtil()
  • Method Details

    • getModifiedUtf8Length

      public static int getModifiedUtf8Length(String string)
      Returns the length of the modified UTF-8 byte array representation of the given string.
    • getModifiedUtf8Bytes

      public static byte[] getModifiedUtf8Bytes(String string)
      Returns the modified UTF-8 byte array representation of the given string.

      Note: surrogate pairs are encoded separately as three byte values as requested by the modified UTF-8 specification. This method is suited for encoding strings stored in class files, dex files or native libraries.

    • getString

      public static String getString(byte[] modifiedUtf8Bytes)
      Returns the String representation of the given modified UTF-8 byte array.
    • getString

      public static String getString(byte[] modifiedUtf8Bytes, int startIndex, int endIndex)
      Returns the String representation of the given modified UTF-8 byte array.
    • join

      public static String join(String separator, String... strings)
      Joins the given strings using the provided separator.
      Parameters:
      separator - The separator to use.
      strings - The strings to join.
      Returns:
      The input strings, concatenated together using the separator
    • toHexString

      public static String toHexString(byte[] bytes)
      Returns the hexadecimal representation of the given byte array.
    • toHexString

      public static String toHexString(byte[] bytes, String separator, boolean upperCase)
      Returns the hexadecimal representation of the given byte array.
    • escapeControlCharacters

      public static String escapeControlCharacters(String input)
      Escapes control characters (\n, \r, \b, \t, \f).
    • listToString

      public static String listToString(List<String> stringList)
      Converts a List of Strings to a nicely readable format. Example: ["foo", "bar", "baz"].