handle zero-length string correctly