string buffers are allocated and reused, meaning that the previous usage of that memory may have had data (not zeroes).
renaming a pokemon does not clear the buffer, so longer nicknames will remain hidden underneath the new nickname & terminator.
for generation 4+ encounters, you are fine grabbing from the database without modification; gens 1-3 do have trash bytes that are poorly understood, but don't matter when transferred to recent games (cleared/reset).