Hi, With 1.6.1.7-rc2, doc says: select*CLI> -= Info about function 'SPRINTF' =- [Syntax] SPRINTF(<format>,<arg1>[,...<argN>]) [Synopsis] Format a variable according to a format string [Description] Parses the format string specified and returns a string matching that format. Supports most options supported by sprintf(3). Returns a shortened string if a format specifier is not recognized. I'm trying use sprintf option allowing to swap argument display according format string. More precisely, I'm trying to this "%1$s" specifier (which means "use 1st argument"). Then, the reply is : ERROR[3185]: func_strings.c:547 acf_sprintf: Format type not supported: '%1$' with argument '1234' Though the message is clear, before giving up, I thought I should ask here if someone could successfully use the "%1$s" specifier (which is very useful when you want to localize some messages or output some command strings). Regards -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20091012/dc58f5e6/attachment.htm
Tilghman Lesher
2009-Oct-12 12:33 UTC
[asterisk-users] SPRINTF option : format %1$s not supported
On Monday 12 October 2009 05:51:31 Olivier wrote:> [Description] > Parses the format string specified and returns a string matching that > format. > Supports most options supported by sprintf(3). Returns a shortened string > if > a format specifier is not recognized. > > > > I'm trying use sprintf option allowing to swap argument display according > format string. > More precisely, I'm trying to this "%1$s" specifier (which means "use 1st > argument"). > Then, the reply is : > ERROR[3185]: func_strings.c:547 acf_sprintf: Format type not supported: > '%1$' with argument '1234' > > Though the message is clear, before giving up, I thought I should ask here > if someone could successfully use the > "%1$s" specifier (which is very useful when you want to localize some > messages or output some command strings).Nope. Dollar ($) format specifiers are not supported at all. Given that the arguments to SPRINTF are specified in a string, you could simply repeat an argument where necessary, which is why I never bothered implementing any of the positional formats. -- Tilghman Lesher Digium, Inc. | Senior Software Developer twitter: Corydon76 | IRC: Corydon76-dig (Freenode) Check us out at: www.digium.com & www.asterisk.org
Steve Murphy
2009-Oct-12 15:32 UTC
[asterisk-users] SPRINTF option : format %1$s not supported
On Mon, Oct 12, 2009 at 4:51 AM, Olivier <oza-4h07 at myamail.com> wrote:> Hi, > > With 1.6.1.7-rc2, doc says: > select*CLI> > -= Info about function 'SPRINTF' =- > > [Syntax] > SPRINTF(<format>,<arg1>[,...<argN>]) > > [Synopsis] > Format a variable according to a format string > > [Description] > Parses the format string specified and returns a string matching that > format. > Supports most options supported by sprintf(3). Returns a shortened string > if > a format specifier is not recognized. > > > > I'm trying use sprintf option allowing to swap argument display according > format string. > More precisely, I'm trying to this "%1$s" specifier (which means "use 1st > argument"). > Then, the reply is : > ERROR[3185]: func_strings.c:547 acf_sprintf: Format type not supported: > '%1$' with argument '1234' > > Though the message is clear, before giving up, I thought I should ask here > if someone could successfully use the > "%1$s" specifier (which is very useful when you want to localize some > messages or output some command strings). >My initial (imho) impression is that localizations in the code, are in general a bad way to approach localization in general. The localizations should be located neither in Asterisk code nor in dialplan code. I know, I know, that such code already exists, but that's still not making my assertion false... murf -- Steve Murphy ParseTree Corp -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20091012/1825c024/attachment.htm