Log in

View Full Version : String(i,"%08d")


rgr
19th March 2026, 18:36
Edit: OK, it should be:
String(i,"%8.0f")


Am I misunderstanding something or is this a bug?

for(i=0, 20) {
LogMsg(String(i)+"="+String(i,"%08d"), LOG_INFO)
}


Manual:
String(123, "%07d") → "0000123"


Output:
---------------------------------------------------------------------
INFO: 0=00000000
---------------------------------------------------------------------
INFO: 1=00000000
---------------------------------------------------------------------
INFO: 2=00000000
---------------------------------------------------------------------
INFO: 3=00000000
---------------------------------------------------------------------
INFO: 4=00000000
---------------------------------------------------------------------
INFO: 5=00000000
---------------------------------------------------------------------
INFO: 6=00000000
---------------------------------------------------------------------
INFO: 7=00000000
---------------------------------------------------------------------
INFO: 8=00000000
---------------------------------------------------------------------
INFO: 9=00000000
---------------------------------------------------------------------
INFO: 10=00000000
---------------------------------------------------------------------
INFO: 11=00000000
---------------------------------------------------------------------
INFO: 12=00000000
---------------------------------------------------------------------
INFO: 13=00000000
---------------------------------------------------------------------
INFO: 14=00000000
---------------------------------------------------------------------
INFO: 15=00000000
---------------------------------------------------------------------
INFO: 16=00000000
---------------------------------------------------------------------
INFO: 17=00000000
---------------------------------------------------------------------
INFO: 18=00000000
---------------------------------------------------------------------
INFO: 19=00000000
---------------------------------------------------------------------
INFO: 20=00000000
---------------------------------------------------------------------

wonkey_monkey
19th March 2026, 18:55
A bug I think. String(...) reads integers as floats, then passes them ultimately to _vsnprintf_l to create the string (I think). I'm guessing something there rejects the float because of the mis-matching format specifier.

String(i, "%08.0f") will do what you want, at least.

qyot27
19th March 2026, 20:56
https://avisynthplus.readthedocs.io/en/latest/avisynthdoc/syntax/syntax_internal_functions_conversion.html#string

Nowhere there does it say it accepts '%08d' as a valid format string. In fact it states 'the leading '%' and trailing 'f' are required!' (bolded for emphasis).