Package ghidra.program.model.data

# Class StringRenderBuilder

java.lang.Object
ghidra.program.model.data.StringRenderBuilder

public class StringRenderBuilder extends Object
Helper class used to build up a formatted (for human consumption) string representation returned by Unicode and String data types.

Call `build()` to retrieve the formatted string.

Example (quotes are part of result): `"Test\tstring",01h,02h,"Second\npart"`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final char`
  `DOUBLE_QUOTE`
  `static final char`
  `SINGLE_QUOTE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StringRenderBuilder(Charset cs, int charSize)`
  `StringRenderBuilder(Charset cs, int charSize, char quoteChar)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addEscapedCodePoint(int codePoint)`
  Add a unicode codepoint as its escaped hex value, with a escape character prefix of 'x', 'u' or 'U' depending on the magnitude of the codePoint value.
  `String`
  `build()`
  `void`
  `decodeBytesUsingCharset(ByteBuffer bb, RenderUnicodeSettingsDefinition.RENDER_ENUM renderSetting, boolean trimTrailingNulls)`
  Adds the characters found in the supplied `ByteBuffer` to the result.
  `String`
  `toString()`
  Example (quotes are part of result): `"Test\tstring",01,02,"Second\npart",00`

  ### Methods inherited from class java.lang.Object

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

- ## Field Details

  - ### DOUBLE_QUOTE

    public static final char DOUBLE_QUOTE
    See Also:
      - Constant Field Values

  - ### SINGLE_QUOTE

    public static final char SINGLE_QUOTE
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### StringRenderBuilder

    public StringRenderBuilder(Charset cs, int charSize)

  - ### StringRenderBuilder

    public StringRenderBuilder(Charset cs, int charSize, char quoteChar)

- ## Method Details

  - ### addEscapedCodePoint

    public void addEscapedCodePoint(int codePoint)
    Add a unicode codepoint as its escaped hex value, with a escape character prefix of 'x', 'u' or 'U' depending on the magnitude of the codePoint value.

    codePoint 15 -> '\' 'x' "0F"
    codePoint 65535 -> '\' 'u' "FFFF"
    codePoint 65536 -> '\' 'U' "00010000"

    Parameters:
      `codePoint` - int value

  - ### decodeBytesUsingCharset

    public void decodeBytesUsingCharset(ByteBuffer bb, RenderUnicodeSettingsDefinition.RENDER_ENUM renderSetting, boolean trimTrailingNulls)
    Adds the characters found in the supplied `ByteBuffer` to the result.

    Any portions of the byte buffer that cause problems for the charset codec will be added as a `byte sequence`.

    Characters that are outside the traditional ASCII range will be rendered as-is or as escape sequences, depending on the RENDER_ENUM setting.

    Parameters:
      `bb` - `ByteBuffer` containing bytes of a string
      `renderSetting` - `RenderUnicodeSettingsDefinition.RENDER_ENUM`
      `trimTrailingNulls` - boolean flag, if true trailing null bytes will not be included in the rendered output

  - ### build

    public String build()

  - ### toString

    public String toString()
    Example (quotes are part of result): `"Test\tstring",01,02,"Second\npart",00`
    Overrides:
      `toString` in class `Object`
    Returns:
      Formatted string