Escape Characters in format()

When using the format function (https://electricimp.com/docs/squirrel/string/format/), is it possible to escape a percent symbol?

server.log(format(“Cloud Cover: %i\%”, clouds));

This didn’t work as I had hoped. I had to do this instead.

server.log(format(“Cloud Cover: %i”, clouds) + “%”);

It works like C’s printf: try “Cloud cover: %i%%”

Peter

That worked… it would be a handy note to have added to the section specifically about escaping characters.

Thanks.

The format() doc does include a note about escaping characters, but I’ve added in the code for the percentage symbol, which hadn’t been included.

Thanks. I had checked over that document before posting and couldn’t find anything.

It might be less misleading to list %% among the format specifiers (inspected by format()) than among the escape characters (inspected by the lexer)?

Also I’ve just noticed the format specifiers doesn’t list “%g”, which has the same meaning as in printf.

Peter