|
| std::string | UTF16ToUTF8 (const uint8_t *utf16, const size_t len) |
| std::string | UTF32ToUTF8 (const uint8_t *utf32) |
| bool | GetBlockRange (const std::string &name, std::pair< uint32_t, uint32_t > &range) |
| std::vector< std::vector< std::pair< uint32_t, uint32_t > > > | GetBlocksForNames (const std::vector< std::string > &names) |
| std::vector< std::string > | GetBlockNames () |
| std::map< std::string, std::pair< uint32_t, uint32_t > > | GetBlockRanges () |
| std::string | GetUTF8String (const std::vector< std::vector< std::pair< uint32_t, uint32_t > > > &unicodeBlocks, const uint8_t *data, const size_t offset, const size_t dataLen) |
| std::string | ToEscapedString (const std::vector< std::vector< std::pair< uint32_t, uint32_t > > > &unicodeBlocks, bool utf8Enabled, const void *data, const size_t dataLen) |
| std::string | ToEscapedString (BinaryView *view, const void *data, size_t dataLen) |
| | Escape a string for display using the Unicode blocks enabled for the given view.
|
| std::string | ToEscapedString (BinaryView *view, std::string_view str) |
| | Escape a string for display using the Unicode blocks enabled for the given view.
|
| size_t | GetDisplayWidth (const std::string &str) |
| | Width of a string in character cells, following Unicode Standard Annex #11 (East Asian Width).
|
| size_t | GetNextGraphemeClusterBoundary (const std::string &str, size_t offset) |
| | Byte offset of the grapheme cluster boundary following the one at offset, which is to say the end of the cluster that starts there.
|
| std::string BinaryNinja::Unicode::ToEscapedString |
( |
BinaryView * | view, |
|
|
const void * | data, |
|
|
size_t | dataLen ) |
Escape a string for display using the Unicode blocks enabled for the given view.
Text that decodes to a codepoint in one of the enabled Unicode blocks is passed through as unaltered UTF8. Everything else is escaped, including bytes that are part of a truncated or otherwise invalid encoding, so the input does not need to be valid UTF8.
This is the escaping renderers should use when emitting string contents, such as the value of a derived string produced by a StringRecognizer.
- Parameters
-
| view | View whose settings determine the enabled blocks, or nullptr for global settings |
| data | Bytes to escape |
| dataLen | Length of data in bytes |
- Returns
- The escaped string
| size_t BinaryNinja::Unicode::GetDisplayWidth |
( |
const std::string & | str | ) |
|
Width of a string in character cells, following Unicode Standard Annex #11 (East Asian Width).
Wide and fullwidth code points, such as CJK ideographs and kana, occupy two cells; combining marks and other zero-width code points occupy none; everything else occupies one. Text that is not valid UTF8 is measured as one cell per byte.
Binary Ninja renders text on a fixed character cell grid, so this, rather than a byte or code point count, is the measurement that InstructionTextToken widths are expressed in.
- Parameters
-
- Returns
- Width of the string in character cells
| size_t BinaryNinja::Unicode::GetNextGraphemeClusterBoundary |
( |
const std::string & | str, |
|
|
size_t | offset ) |
Byte offset of the grapheme cluster boundary following the one at offset, which is to say the end of the cluster that starts there.
It is the caller's responsibility to pass a boundary: offset must be zero, the length of the string, or a value this returned. Only the cluster at offset is examined, so walking a string a cluster at a time this way costs no more than the clusters it visits.
for (size_t start = 0, end; start < str.size(); start = end)
{
}
- Parameters
-
| str | String the offset refers to, which need not be valid UTF8 |
| offset | Byte offset of a cluster boundary |
- Returns
- The offset of the next cluster boundary, or the length of the string if there is none