string.formatwith implementation