serialize: Avoid stray nul characters when auto-serializing char.

Fixes #19719.