alexei / sprintf.js

sprintf.js is a complete open source JavaScript sprintf implementation
BSD 3-Clause "New" or "Revised" License
2.11k stars 291 forks source link

Does not support the # flag #79

Open pmast opened 8 years ago

pmast commented 8 years ago

sprintf("% #6f", "2")results in a SyntaxError: [sprintf] unexpected placeholder

From man printf:

Each format specification is introduced by the percent character ("%'').  The remainder of the format specification includes, in the following order:

Zero or more of the following flags:
 #       A `#' character specifying that the value should be printed in an "alternate 
form". For c, d, and s, formats, this option has no effect.  For the o formats the 
precision of the number is increased to force the first character of the output string 
to a zero.  For the x (X) format, a non-zero result has the string 0x (0X) prepended 
to it.  For e, E, f, g, and G, formats, the result will always contain a decimal point, 
even if no digits follow the point (normally, a decimal point only appears in the results 
of those formats if a digit follows the decimal point).  For g and G formats, trailing 
zeros are not removed from the result as they would otherwise be;
alexei commented 8 years ago

That's interesting. Will think about this.