Fix handling of '~n' format string