match MRI behaviour of omitting trailing nulls