Skip to content

Don't printf wstring_views by copying them into wstrings; use %.*s! #4027

@DHowett-MSFT

Description

@DHowett-MSFT

StringCchPrintf and--since C99--printf support a specifier that indicates that a string is counted:

auto size = /* ... */;
auto data = /* ... */;
printf("%.*s", size, data);

The .* suggests that printf should consume one register-width argument to determine how many characters the string that follows contains instead of waiting for a null terminator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-CodeHealthIssues related to code cleanliness, linting, rules, warnings, errors, static analysis, etc.Help WantedWe encourage anyone to jump in on these.Issue-TaskIt's a feature request, but it doesn't really need a major design.Product-ConhostFor issues in the Console codebaseProduct-TerminalThe new Windows Terminal.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions