MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / fmtByteString

Function fmtByteString

binaryninjaapi.cpp:472–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

470
471
472fmt::format_context::iterator fmtByteString(const std::vector<uint8_t>& string, fmt::format_context& ctx)
473{
474 *ctx.out()++ = 'b';
475 *ctx.out()++ = '\"';
476 for (uint8_t ch: string)
477 {
478 if (ch == '\n')
479 {
480 *ctx.out()++ = '\\';
481 *ctx.out()++ = 'n';
482 }
483 else if (ch == '\r')
484 {
485 *ctx.out()++ = '\\';
486 *ctx.out()++ = 'r';
487 }
488 else if (ch == '\t')
489 {
490 *ctx.out()++ = '\\';
491 *ctx.out()++ = 't';
492 }
493 else if (ch == '\"')
494 {
495 *ctx.out()++ = '\\';
496 *ctx.out()++ = '\"';
497 }
498 else if (ch == '\\')
499 {
500 *ctx.out()++ = '\\';
501 *ctx.out()++ = '\\';
502 }
503 else if (ch < 0x20 || ch >= 0x7f)
504 {
505 fmt::format_to(ctx.out(), "\\x{:02x}", ch);
506 }
507 else
508 {
509 *ctx.out()++ = ch;
510 }
511 }
512 *ctx.out()++ = '\"';
513 return ctx.out();
514}
515
516
517fmt::format_context::iterator fmtQuotedString(const std::string& string, fmt::format_context& ctx)

Callers 1

formatMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected