Package ghidra.program.model.data
Class StringRenderBuilder
java.lang.Object
ghidra.program.model.data.StringRenderBuilder
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
-
Constructor Summary
ConstructorDescriptionStringRenderBuilder
(Charset cs, int charSize) StringRenderBuilder
(Charset cs, int charSize, char quoteChar) -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.build()
void
decodeBytesUsingCharset
(ByteBuffer bb, RenderUnicodeSettingsDefinition.RENDER_ENUM renderSetting, boolean trimTrailingNulls) Adds the characters found in the suppliedByteBuffer
to the result.toString()
Example (quotes are part of result):"Test\tstring",01,02,"Second\npart",00
-
Field Details
-
DOUBLE_QUOTE
public static final char DOUBLE_QUOTE- See Also:
-
SINGLE_QUOTE
public static final char SINGLE_QUOTE- See Also:
-
-
Constructor Details
-
StringRenderBuilder
-
StringRenderBuilder
-
-
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 suppliedByteBuffer
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 stringrenderSetting
-RenderUnicodeSettingsDefinition.RENDER_ENUM
trimTrailingNulls
- boolean flag, if true trailing null bytes will not be included in the rendered output
-
build
-
toString
Example (quotes are part of result):"Test\tstring",01,02,"Second\npart",00
-