# Class: com.pnfsoftware.jeb.core.units.code.asm.items.DataStringUtil

Utility methods to facilitate the creation of string items by the [INativeDataAnalyzer](INativeDataAnalyzer).

## Constructor: DataStringUtil


## Static Field: NAME_DEFAULT_LENGTH
Type: `int`

Constant value: `16`

## Static Field: NAME_PREFIX
Type: `java.lang.String`

Constant value: `a`

## Static Field: maxStringItemNameLength
Type: `int`

Constant value: `64`

## Static Method: createFromMemory
- parameter: `dataParser`, type: `com.pnfsoftware.jeb.core.units.code.asm.analyzer.INativeDataAnalyzer`
- parameter: `labelman`, type: `com.pnfsoftware.jeb.core.units.code.asm.analyzer.ILabelManager`
- parameter: `mem`, type: `com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory`
- parameter: `address`, type: `long`
- parameter: `addressMax`, type: `long`
- parameter: `stringType`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.StringEncoding`
- parameter: `minChars`, type: `int`
- parameter: `maxChars`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.items.INativeStringItem`

Description: Parse a memory area as a string. If a non\-null string item is returned, it must be registered to a memory model or immediately disposed.
parameter: dataParser: 
parameter: labelman: label manager
parameter: mem: virtual memory
parameter: address: mandatory start address
parameter: addressMax: optional maximum \(final\) address for the string; use \-1 for no limit
parameter: stringType: the string type hint; null to let this method determine the best string            type heuristically
parameter: minChars: minimum number of characters to be found in the string for it to be            considered valid \(inclusive\); set to \-1 for default \(currently: 3\)
parameter: maxChars: maximum number of characters \(not bytes\) to be parsed \(exclusive\); set to \-1            for default \(currently: 100\_000\)
return: a string item or null

## Static Method: createItemNameFromString
- parameter: `str`, type: `java.lang.String`
- parameter: `maxLength`, type: `int`
- return type: `java.lang.String`

Description: Generate a default name for a String, starting with default prefix [#NAME_PREFIX](#NAME_PREFIX), and replacing non identifier characters by '\_'
parameter: str: string
parameter: maxLength: max length of generated name. Use [#NAME_DEFAULT_LENGTH](#NAME_DEFAULT_LENGTH) if unknown.
return: a legal item name

## Static Method: determineValue
- parameter: `item`, type: `com.pnfsoftware.jeb.core.units.code.asm.items.INativeStringItem`
- parameter: `mem`, type: `com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory`
- parameter: `reEncodingValidation`, type: `boolean`
- return type: `java.lang.String`

Description: Determine the value of a given string data item.
parameter: item: 
parameter: mem: 
parameter: reEncodingValidation: 
return: 

## Static Method: determineValue
- parameter: `st`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.StringEncoding`
- parameter: `mem`, type: `com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory`
- parameter: `address`, type: `long`
- parameter: `size`, type: `int`
- parameter: `reEncodingValidation`, type: `boolean`
- return type: `java.lang.String`

Description: Determine the value of a string.
parameter: st: string type
parameter: mem: virtual memory
parameter: address: address to string in memory
parameter: size: string size in bytes, including the terminator if any
parameter: reEncodingValidation: 
return: 

## Static Method: determineValue
- parameter: `st`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.StringEncoding`
- parameter: `buffer`, type: `byte[]`
- parameter: `offset`, type: `int`
- parameter: `size`, type: `int`
- parameter: `reEncodingValidation`, type: `boolean`
- return type: `java.lang.String`

Description: Determine the value of a string.
parameter: st: string type
parameter: buffer: bytes
parameter: offset: offset to string in buffer
parameter: size: string size in byte, including the null terminator if any
parameter: reEncodingValidation: 
return: 

## Static Method: getStringAt
- parameter: `mem`, type: `com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory`
- parameter: `address`, type: `long`
- parameter: `minChars`, type: `int`
- parameter: `maxChars`, type: `int`
- return type: `java.lang.String`

Description: Attempt to create a string from the memory bytes located at the provided address.
parameter: mem: virtual memory
parameter: address: start address
parameter: minChars: minimum number of characters allowed for the string
parameter: maxChars: maximum number of characters allowed for the string
return: a string or null

## Static Method: getStringAt
- parameter: `mem`, type: `com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory`
- parameter: `address`, type: `long`
- parameter: `minChars`, type: `int`
- parameter: `maxChars`, type: `int`
- parameter: `atype`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.StringEncoding[]`
- return type: `java.lang.String`

Description: Attempt to create a string from the memory bytes located at the provided address.
parameter: mem: virtual memory
parameter: address: start address
parameter: minChars: minimum number of characters allowed for the string
parameter: maxChars: maximum number of characters allowed for the string
parameter: atype: optional single\-element array to collect the string output type
return: a string or null

## Static Method: getStringAt
- parameter: `mem`, type: `com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory`
- parameter: `address`, type: `long`
- parameter: `addressMax`, type: `long`
- parameter: `minChars`, type: `int`
- parameter: `maxChars`, type: `int`
- return type: `com.pnfsoftware.jeb.core.units.code.asm.items.StringEntry`

Description: Attempt to create a string from the memory bytes located at the provided address.
parameter: mem: virtual memory
parameter: address: start address
parameter: addressMax: max address \(use \-1 to specify no\-max\)
parameter: minChars: minimum number of characters allowed for the string
parameter: maxChars: maximum number of characters allowed for the string
return: a string descriptor or null

## Static Method: getValidStringAt
- parameter: `model`, type: `com.pnfsoftware.jeb.core.units.code.asm.analyzer.INativeCodeModel<?>`
- parameter: `mem`, type: `com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory`
- parameter: `address`, type: `long`
- parameter: `minChars`, type: `int`
- parameter: `maxChars`, type: `int`
- return type: `java.lang.String`

Description: Determine whether the memory bytes at the provided address look like a string and return its value. Check named overlapping items.
parameter: model: native model to validate there is no overlap. If null, validation won't be            performed.
parameter: mem: virtual memory
parameter: address: start address
parameter: minChars: minimum number of characters allowed for the string
parameter: maxChars: maximum number of characters allowed for the string
return: a string or null

## Static Method: heurIsValidString
- parameter: `s`, type: `java.lang.String`
- parameter: `minChars`, type: `int`
- return type: `boolean`


## Static Method: isSafeAsciiCharArrayAt
- parameter: `mem`, type: `com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory`
- parameter: `address`, type: `long`
- parameter: `size`, type: `int`
- return type: `boolean`

Description: Indicate if there is an ascii char array at a given address. Some extra characters are allowed, implementation is based on [Characters#isAsciiCharOrCommonFormat(int)](Characters#isAsciiCharOrCommonFormat(int))
parameter: mem: virtual memory
parameter: address: char array address
parameter: size: array size
return: true if there is a valid only\-ascii char array

## Static Method: isSafeAsciiStringAt
- parameter: `mem`, type: `com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory`
- parameter: `address`, type: `long`
- parameter: `minChars`, type: `int`
- parameter: `maxChars`, type: `int`
- return type: `boolean`


## Static Method: isSafeAsciiStringAt
- parameter: `mem`, type: `com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory`
- parameter: `address`, type: `long`
- parameter: `st`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.StringEncoding`
- parameter: `minChars`, type: `int`
- parameter: `maxChars`, type: `int`
- return type: `boolean`

Description: Indicate if a data in memory is a safe ASCII \(meaning containing only printable character in the ASCII range\). Does not consider extended ASCII. Note that String Type can be different from [StringEncoding#ASCII_ZERO](StringEncoding#ASCII_ZERO): it will still check the ASCII range.
parameter: mem: virtual memory
parameter: address: String address
parameter: st: String type
parameter: minChars: minimum number of characters expected
parameter: maxChars: maximum number of characters to be parsed \(withouh the final zero if any\)
return: 

## Static Method: isValidCharAt
- parameter: `mem`, type: `com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory`
- parameter: `address`, type: `long`
- parameter: `endAddress`, type: `long`
- parameter: `st`, type: `com.pnfsoftware.jeb.core.units.code.asm.type.StringEncoding`
- return type: `boolean`

Description: Determine of char at a given address is valid. Does not build the full String sequences.
parameter: mem: virtual memory
parameter: address: Char address
parameter: endAddress: end address
parameter: st: String type. Must not be null.
return: true if there is a valid character regarding its encoding.

## Static Method: isValidStringAt
- parameter: `model`, type: `com.pnfsoftware.jeb.core.units.code.asm.analyzer.INativeCodeModel<?>`
- parameter: `mem`, type: `com.pnfsoftware.jeb.core.units.code.asm.memory.IVirtualMemory`
- parameter: `address`, type: `long`
- parameter: `minChars`, type: `int`
- parameter: `maxChars`, type: `int`
- return type: `boolean`

Description: Determine whether the memory bytes at the provided address look like a string. Check named overlapping items.
parameter: model: 
parameter: mem: virtual memory
parameter: address: start address
parameter: minChars: minimum number of characters allowed for the string
parameter: maxChars: maximum number of characters allowed for the string
return: a string or null

