Class CharsetInfo


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

    See charset_info.xml to specify a custom charset.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String USASCII  
      static java.lang.String UTF16  
      static java.lang.String UTF32  
      static java.lang.String UTF8  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getCharsetCharSize​(java.lang.String charsetName)
      Returns the number of bytes that the specified charset needs to specify a character.
      java.lang.String[] getCharsetNames()
      Returns an array list of the currently configured charsets.
      java.util.List<java.lang.String> getCharsetNamesWithCharSize​(int size)
      Returns list of Charsets that encode with the number of bytes specified.
      static CharsetInfo getInstance()
      Get the global singleton instance of this CharsetInfo.
      static boolean isBOMCharset​(java.lang.String charsetName)  
      static void reinitializeWithUserDefinedCharsets()
      Reinitialize registered Charsets and include user defined Charsets specified in charset_info.xml.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static CharsetInfo getInstance()
        Get the global singleton instance of this CharsetInfo.
        Returns:
        global singleton instance
      • isBOMCharset

        public static boolean isBOMCharset​(java.lang.String charsetName)
        Parameters:
        charsetName - name of charset
        Returns:
        true if the supported multi-byte charset does not specify LE or BE
      • reinitializeWithUserDefinedCharsets

        public static void reinitializeWithUserDefinedCharsets()
        Reinitialize registered Charsets and include user defined Charsets specified in charset_info.xml.
      • getCharsetNames

        public java.lang.String[] getCharsetNames()
        Returns an array list of the currently configured charsets.
        Returns:
        String[] of current configured charsets.
      • getCharsetCharSize

        public int getCharsetCharSize​(java.lang.String charsetName)
        Returns the number of bytes that the specified charset needs to specify a character.
        Parameters:
        charsetName - charset name
        Returns:
        number of bytes in a character, ie. 1, 2, 4, etc, defaults to 1 if charset is unknown or not specified in config file.
      • getCharsetNamesWithCharSize

        public java.util.List<java.lang.String> getCharsetNamesWithCharSize​(int size)
        Returns list of Charsets that encode with the number of bytes specified.
        Parameters:
        size - the number of bytes for the Charset encoding.
        Returns:
        Charsets that encode one byte characters.