Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

print nothing on %n #223

Open
ctr49 opened this issue Jun 12, 2023 · 4 comments
Open

print nothing on %n #223

ctr49 opened this issue Jun 12, 2023 · 4 comments

Comments

@ctr49
Copy link

ctr49 commented Jun 12, 2023

POSIX C/C++ sprintf have a specifier "n" that prints nothing. This can be useful in some cases to suppress content.

Would you mind implementing %n to print nothing in sprint.js?

Thanks!

@alexei
Copy link
Owner

alexei commented Jun 13, 2023

What are the use cases?

@ctr49
Copy link
Author

ctr49 commented Jul 5, 2023

In my case I use CometVisu as home automation visualization. It uses sprint.js and allows formatting with it. For my custom visualization I sometimes want to suppress output and there is currently no way to do so.

In general I suppose the use case is exactly the same as %n in C

@alexei
Copy link
Owner

alexei commented Sep 11, 2023

@ctr49 I kind of like this idea, see #228

There's one thing I'm undecided about. %n in C doesn't accept any options, however I think it would be cool if it did e.g. %+'#10n would result in ########## (i.e. as opposed to an empty string). What do you think about this?

@ctr49
Copy link
Author

ctr49 commented Sep 13, 2023

#228 looks great, thanks!

Regarding the option I can see the point where such a syntax may make sense, but I'm not sure if overloading "n" (having a specific meaning in original sprintf) is self-explanatory or if it deserves a dedicated (conflict-free) option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants