Skip to content

[C++] Check if CHAR fields are printable #715

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
trozen opened this issue Sep 12, 2019 · 2 comments
Closed

[C++] Check if CHAR fields are printable #715

trozen opened this issue Sep 12, 2019 · 2 comments

Comments

@trozen
Copy link
Contributor

trozen commented Sep 12, 2019

Sometimes I'm getting messages with CHAR fields, that are set to 0 for example. This breaks logging, as binary data is mixed with text.

Would it be possible to change the way CHAR fields are printed currently:

            builder << '"' << (char)writer.tradeCondition() << '"';

to something like:

            if (std::isprint(writer.tradeCondition())) {
                builder << '"' << (char)writer.tradeCondition() << '"';
            } else {
                builder << (int)writer.tradeCondition();
            }
@tmontgomery
Copy link
Contributor

Feel free to send a PR for this.

@rigtorp
Copy link
Contributor

rigtorp commented Sep 13, 2019

Remember this will cause the output to be locale dependent.

@trozen trozen closed this as completed Sep 16, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants