Based on the functionality of the Perl implementation of sprintf.