Class CharsetInfo

java.lang.Object
ghidra.util.charset.CharsetInfo

public class CharsetInfo extends Object
Additional information about java.nio.charset.Charset's that Ghidra needs to be able to create Ghidra string datatype instances.

See charset_info.json to specify info about a custom charset.

  • Constructor Details

    • CharsetInfo

      public CharsetInfo(Charset cs)
    • CharsetInfo

      public CharsetInfo(String name, String comment, int minBytesPerChar, int maxBytesPerChar, int alignment, int codePointCount, boolean standardCharset, boolean canProduceError, EnumSet<Character.UnicodeScript> scripts, Set<String> contains)
  • Method Details

    • withComment

      public CharsetInfo withComment(String newComment)
      Returns a copy of this instance, with a new comment value.
      Parameters:
      newComment - string
      Returns:
      a copy of this instance, with a new comment value
    • getCharset

      public Charset getCharset()
      Returns:
      Charset
    • getName

      public String getName()
      Returns name of the charset.
      Returns:
      name of the charset
    • isStandardCharset

      public boolean isStandardCharset()
      Returns boolean flag, true if this is a standard charset that is guaranteed to be present in the jvm, otherwise false.
      Returns:
      boolean flag, true if this is a standard charset that is guaranteed to be present in the jvm, otherwise false
    • isCanProduceError

      public boolean isCanProduceError()
      Returns true if this charset can produce Unicode REPLACEMENT codepoints for bad byte sequences, otherwise false if there are no byte sequences that result in REPLACEMENT codepoints. This is typically single-byte charsets that map all byte values to a codepoint.
      Returns:
      true if this charset can produce Unicode REPLACEMENT codepoints for bad byte sequences, otherwise false if there are no byte sequences that result in REPLACEMENT codepoints. This is typically single-byte charsets that map all byte values to a codepoint
    • supportsAllScripts

      public boolean supportsAllScripts()
      Returns true if this charset can produce Unicode codepoints that are in all scripts.
      Returns:
      true if this charset can produce Unicode codepoints that are in all scripts
    • getScripts

      public Set<Character.UnicodeScript> getScripts()
      Returns the UnicodeScripts that this charset can produce.
      Returns:
      the UnicodeScripts that this charset can produce
    • hasFixedLengthChars

      public boolean hasFixedLengthChars()
      Returns true if this charset only consumes a fixed number of bytes per output codepoint.
      Returns:
      true if this charset only consumes a fixed number of bytes per output codepoint
    • getAlignment

      public int getAlignment()
      Returns the alignment value for this charset, typically 1 for most charsets, but for well-known fixed-width charsets, it will return those charsets fixed-width.
      Returns:
      the alignment value for this charset, typically 1 for most charsets, but for well-known fixed-width charsets, it will return those charsets fixed-width
    • getMinBytesPerChar

      public int getMinBytesPerChar()
      Returns the smallest number of bytes needed to produce a codepoint.
      Returns:
      the smallest number of bytes needed to produce a codepoint
    • getMaxBytesPerChar

      public int getMaxBytesPerChar()
      Returns the largest number of bytes needed to produce a codepoint.
      Returns:
      the largest number of bytes needed to produce a codepoint
    • getCodePointCount

      public int getCodePointCount()
      Returns the number of codepoints that this charset can produce.
      Returns:
      the number of codepoints that this charset can produce
    • getContains

      public Set<String> getContains()
      Returns the names of other charsets that this charset Charset.contains(Charset).
      Returns:
      names of other charsets
    • getComment

      public String getComment()
      Returns a string comment describing this charset, or null.
      Returns:
      a string comment describing this charset, or null
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object